Http status 404 error in struts!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajos
    Contributor
    • Aug 2007
    • 283

    #1

    Http status 404 error in struts!!

    hi frnds,
    the situation is im developing a web application in struts--
    my specifications-eclipse3.2.2,st ruts1.1,tomcat5 .5.23 mysql5.0 db.
    the scenario-i have a jsp page which adds the records in the db.when the user clicks submit,a javascript gets fired and checks the validation.on submit the BdgMastAction.j ava does all the data access and forwards the control to a jsp named bdgm.jsp.the results are displayed in the jsp.the values are stored in a java bean for the views to display it.
    the problem is when i click on submit Http Status 404 error shows up,also there is nothing in the stack trace that conveys the error.
    herrz my code

    BdgMastAction.j ava

    Code:
    package publicity;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import java.sql.SQLWarning;
    import java.sql.Statement;
    
    import javax.sql.DataSource;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.sql.*;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionServlet;
    
    import com.mysql.jdbc.ResultSet;
    
    public class BdgMastAction extends Action 
    {
    	private Connection con;
    	//private DataSource datasource=null;
    	private ResultSet resultset;
    	private PrintWriter out;
    	//DBConnect dbc=new DBConnect();
    	
    	public ActionForward execute(ActionMapping mapping,ActionForm form,
    			HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse)throws Exception
    	{
    		
    			//datasource=getDataSource(httpservletrequest);
    			//connection=datasource.getConnection();
    		try
    			{
    				Class.forName("com.mysql.jdbc.Driver");
    			}
    			catch(ClassNotFoundException cnfe)
    			{
    				System.out.println("coudnt load class com.mysql.jdbc.Driver"+ cnfe);
    			
    	}
    		BdgtMasForm bmf=(BdgtMasForm) form;
    		bmf.setBranch(httpservletrequest.getParameter("branch"));
    		bmf.setBudget(httpservletrequest.getParameter("budget"));
    		bmf.setOption(httpservletrequest.getParameter("option"));
    		bmf.setPublicity_Code(httpservletrequest.getParameter("publicity_code"));
    		
    				
    				String s3=null;
    				String s4 = "";
    				String s2 = httpservletrequest.getParameter("option");
    		        s3 = httpservletrequest.getParameter("branch");
    		        s4 = httpservletrequest.getParameter("publicity_code");
    		        String s5 = httpservletrequest.getParameter("budget");
    		        
    		        try
    		        {
    		            String s6 = "0";
    		            String s7 = "0";
    		            String s8 = "INSERT INTO Budget_Master(Branch,Publicity_Code,Budget_Alloted,Work_In_Progress,Amount_Paid) VALUES (?,?,?,?,?)";
    		            String s9 = "update budget_master set old_budget = budget_alloted where branch='" + s3 + "' and publicity_code=" + s4;
    		            String s10 = "UPDATE Budget_Master set budget_alloted=" + s5 + " where Branch='" + s3 + "' and publicity_code=" + s4;
    		            //datasource = "jdbc:odbc:budget";
    		            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/publicity_db","db_user","test");
    		            int i = con.getTransactionIsolation();
    		            con.setTransactionIsolation(2);
    		            con.setAutoCommit(false);
    		            if("new".equalsIgnoreCase(s2))
    		            {
    		                PreparedStatement preparedstatement = con.prepareStatement(s8);
    		                preparedstatement.setString(1, s3);
    		                preparedstatement.setString(2, s4);
    		                preparedstatement.setString(3, s5);
    		                preparedstatement.setString(4, s7);
    		                preparedstatement.setString(5, s6);
    		                preparedstatement.executeUpdate();
    		                con.commit();
    		                preparedstatement.close();
    		            }
    		            if("update".equalsIgnoreCase(s2))
    		            {
    		                Statement statement = con.createStatement();
    		                statement.executeUpdate(s9);
    		                statement.executeUpdate(s10);
    		                con.commit();
    		            }
    		            con.setTransactionIsolation(2);
    		            
    					
    		            con.close();
    		        }
    		        catch(SQLException sqlexception)
    		        {
    		            cleanUp();
    		            printSQLException(sqlexception);
    		        }
    		        out.flush();
    		          
    		        return(mapping.findForward("bdgm"));
    		     
    		    }
    		    
    
    		        static void printSQLException(SQLException sqlexception)
    		        throws IOException
    		    {
    		        System.out.print("<b>SQLException</b>\n<p>\n\n");
    		        for(; sqlexception != null; sqlexception = sqlexception.getNextException())
    		        {
    		            System.out.println("<b>SQLState:</b> " + sqlexception.getSQLState() + "<br>\n");
    		            System.out.println("<b>Message:</b> " + sqlexception.getMessage() + "<br>\n");
    		            System.out.println("<b>Vendor:</b> " + sqlexception.getErrorCode() + "<br>\n");
    		        }
    
    		    }
    
    		    String link(String s, String s1)
    		    {
    		        return "<a href=\"" + s + "\">" + s1 + "</a>";
    		    }
    
    		   
    		    public void cleanUp()
    		        throws IOException
    		    {
    		        if(con != null)
    		            try
    		            {
    		                out.print("Closing database connection");
    		                con.setTransactionIsolation(0);
    		                con.close();
    		                return;
    		            }
    		            catch(SQLException _ex)
    		            {
    		                return;
    		            }
    		        else
    		        	
    		           return;
    		    
    		        
    		
    				
    	}
    	
    
    }
    addbdgt.jsp(the first page where i enter the records)

    [HTML]
    <%@ page language="java" contentType="te xt/html; charset=ISO-8859-1"
    pageEncoding="I SO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <html>
    <head>
    <title>Budget Master Administration</title>
    <meta name="GENERATOR " content="Micros oft FrontPage 3.0">
    <SCRIPT LANGUAGE="JavaS cript" SRC="bscript.js "></SCRIPT>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    </head>
    <body topmargin="0" leftmargin="0" bgproperties="f ixed">
    <div align="left">
    <form name="arch" method="get" action="/BdgMastAction.d o">
    <table border="0" width="100%">
    <tr>
    <td width="100%" bgcolor="#DFDFF F" background="ima ges/niceblue.gif">< font face="Tahoma"
    color="#000000" ><strong>B u d g e t&nbsp;&nbsp; M a s t e r</strong></font></td>
    </tr>
    </table>
    <div align="left">

    <table width="60%" height="127">
    <tr>
    <td valign="top" width="50%" height="34"><st rong><small><fo nt face="Verdana"> </font></small></strong></td>
    <td width="50%" height="34"></td>
    </tr>
    <tr>
    <td valign="top" width="50%" height="27"><st rong><small><fo nt face="Verdana"> Branch</font></small></strong></td>
    <td width="50%" height="27">
    <input type=hidden name="option" value="new">
    <p><select name="branch" size="1">
    <option value="Bombay"> Bombay</option>
    <option value="Delhi">D elhi</option>
    <option value="Ahmedaba d">Ahmedabad </option>
    <option value="Madras"> Madras</option>
    <option value="Bangalor e">Bangalore </option>
    <option value="Calcutta ">Calcutta</option>
    <option value="Hyderaba d">Hyderabad </option>
    <option value="Pune">Pu ne</option>
    <option value="Lucknow" >Lucknow</option>
    <option value="Jaipur"> Jaipur</option>
    <option value="Patna">P atna</option>
    <option value="Cochin"> Cochin</option>
    <option value="Chandiga rh">Chandigar h</option>
    <option value="Bhopal"> Bhopal</option>
    </select></p>
    </td>
    </tr>
    <tr>
    <td width="50%" height="25"><st rong><small><fo nt face="Verdana"> Publicity Code </font></small></strong></td>
    <td width="50%" height="25"><in put type="text" size="5" maxlength="5"
    name="publicity _code"></td>
    </tr>
    <tr>
    <td width="50%" height="25"><st rong><small><fo nt face="Verdana"> Annual Budget Alloted (<em>Rs</em>)</font></small></strong></td>
    <td width="50%" height="25"><in put type="text" size="10" maxlength="10" name="budget"></td>
    </tr>
    </table>
    </div>

    <p align="left"><i nput type="button" name="thesubmit " value="Submit"
    onclick="everyt hing(form)">&nb sp; </p>

    <hr>
    <strong><small> <font color="#0080C0" >

    <p align="center"> ©</font><font color="#0080C0" face="Verdana"> Response - Corporate
    1998-1999</font></small></strong>
    </form>
    </div>

    </body>
    </html>
    [/HTML]

    struts-config.xml
    <form-bean

    name="BdgtMasFo rm"

    type="publicity .BdgtMasForm"/>

    <action-mappings>
    <!-- Default "Welcome" action -->

    <!-- Forwards to Welcome.jsp -->
    <action

    path="/index"

    type="org.apach e.struts.action s.ForwardAction "

    parameter="/index.jsp"/>

    <action

    path="/bdgm"

    type="org.apach e.struts.action s.ForwardAction "

    parameter="/pages/serview/bdgm.jsp"/>

    <action

    path="/addbdgt"

    type="org.apach e.struts.action s.ForwardAction "

    parameter="/pages/admin/addbdgt.jsp"/>



    <action

    path="/BdgMastAction"

    type="publicity .BdgMastAction"

    name="BdgtMasFo rm"

    scope="request"

    validate="true"

    input="/pages/admin/addbdgt.jsp">


    <forward name="bdgm" path="/pages/serview/bdgm.jsp"/>
    </action>

    </action-mappings>
    love to hear from u guyz..plz help
    regards,
    ajos
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    404 should be something about the page not being found.
    Either your path is wrong or the server is down when you try to display the JSP.
    Last edited by r035198x; Sep 10 '07, 12:15 PM. Reason: the code tags bug had struck again

    Comment

    • ajos
      Contributor
      • Aug 2007
      • 283

      #3
      Originally posted by r035198x
      404 should be something about the page not being found.
      Either your path is wrong or the server is down when you try to display the JSP.
      hi r035198x,
      thanx for the response:)
      i know its got to do with page not being found..but ive checked the path also the server is working fine...i cant undrstnd wats the problem....this page is working fine if i use servlets and jsp's.im not able to figure it out....even the code seems to be right...plz help
      regards,
      ajos

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by ajos
        hi r035198x,
        ....this page is working fine if i use servlets and jsp's...
        So when did you say it's not working?

        Comment

        • ajos
          Contributor
          • Aug 2007
          • 283

          #5
          Originally posted by r035198x
          So when did you say it's not working?
          hi,
          this project was previously running in servlets smoothly...im converting it into struts....when i click on the submit button error like-

          HTTP Status 404 - /BdgMastAction.d o

          --------------------------------------------------------------------------------

          type Status report

          message /BdgMastAction.d o

          description The requested resource (/BdgMastAction.d o) is not available.


          --------------------------------------------------------------------------------

          Apache Tomcat/5.5.23
          pops up..i cannot figure out wats wrong since it seems to be right(even though its not!!)..wat possibly can be wrong....any suggestions advice r035198x??

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by ajos
            .. r035198x??
            Unfortunately (or rather fortunately for me) I don't know any Struts. Maybe someone else will be able to help you out.

            P.S It's also quite unfortunate that you picked ajos for a handle.

            Comment

            • ajos
              Contributor
              • Aug 2007
              • 283

              #7
              Originally posted by r035198x
              P.S It's also quite unfortunate that you picked ajos for a handle.
              hi,
              y is that...thats my short name...ive come to know abt the the guy u r reffering to when i joined the forum...i didnt intend to be a imitaion for that guy...or to offend anybdy...my appologies if i have....:)
              regards,
              ajos

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Originally posted by ajos
                hi,
                y is that...thats my short name...ive come to know abt the the guy u r reffering to when i joined the forum...i didnt intend to be a imitaion for that guy...or to offend anybdy...my appologies if i have....:)
                regards,
                ajos
                Nah, it doesn't offend me. I doubt if it offends that other guy as well.

                I just think it's unfortunate that's all.

                regards
                ! a Jos

                Comment

                • ajos
                  Contributor
                  • Aug 2007
                  • 283

                  #9
                  hi frnds,
                  is ther anybdy who can help me in this regard(struts). ....plz help guyz.......
                  regards,
                  ajos

                  Comment

                  Working...