By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,600 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,600 IT Pros & Developers. It's quick & easy.

Http status 404 error in struts!!

100+
P: 283
hi frnds,
the situation is im developing a web application in struts--
my specifications-eclipse3.2.2,struts1.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.java 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.java

Expand|Select|Wrap|Line Numbers
  1. package publicity;
  2. import java.io.IOException;
  3. import java.io.PrintWriter;
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6. import java.sql.PreparedStatement;
  7. import java.sql.SQLException;
  8. import java.sql.SQLWarning;
  9. import java.sql.Statement;
  10.  
  11. import javax.sql.DataSource;
  12. import javax.servlet.ServletResponse;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15. import javax.sql.*;
  16. import org.apache.struts.action.Action;
  17. import org.apache.struts.action.ActionError;
  18. import org.apache.struts.action.ActionMapping;
  19. import org.apache.struts.action.ActionErrors;
  20. import org.apache.struts.action.ActionForm;
  21. import org.apache.struts.action.ActionForward;
  22. import org.apache.struts.action.ActionServlet;
  23.  
  24. import com.mysql.jdbc.ResultSet;
  25.  
  26. public class BdgMastAction extends Action 
  27. {
  28.     private Connection con;
  29.     //private DataSource datasource=null;
  30.     private ResultSet resultset;
  31.     private PrintWriter out;
  32.     //DBConnect dbc=new DBConnect();
  33.  
  34.     public ActionForward execute(ActionMapping mapping,ActionForm form,
  35.             HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse)throws Exception
  36.     {
  37.  
  38.             //datasource=getDataSource(httpservletrequest);
  39.             //connection=datasource.getConnection();
  40.         try
  41.             {
  42.                 Class.forName("com.mysql.jdbc.Driver");
  43.             }
  44.             catch(ClassNotFoundException cnfe)
  45.             {
  46.                 System.out.println("coudnt load class com.mysql.jdbc.Driver"+ cnfe);
  47.  
  48.     }
  49.         BdgtMasForm bmf=(BdgtMasForm) form;
  50.         bmf.setBranch(httpservletrequest.getParameter("branch"));
  51.         bmf.setBudget(httpservletrequest.getParameter("budget"));
  52.         bmf.setOption(httpservletrequest.getParameter("option"));
  53.         bmf.setPublicity_Code(httpservletrequest.getParameter("publicity_code"));
  54.  
  55.  
  56.                 String s3=null;
  57.                 String s4 = "";
  58.                 String s2 = httpservletrequest.getParameter("option");
  59.                 s3 = httpservletrequest.getParameter("branch");
  60.                 s4 = httpservletrequest.getParameter("publicity_code");
  61.                 String s5 = httpservletrequest.getParameter("budget");
  62.  
  63.                 try
  64.                 {
  65.                     String s6 = "0";
  66.                     String s7 = "0";
  67.                     String s8 = "INSERT INTO Budget_Master(Branch,Publicity_Code,Budget_Alloted,Work_In_Progress,Amount_Paid) VALUES (?,?,?,?,?)";
  68.                     String s9 = "update budget_master set old_budget = budget_alloted where branch='" + s3 + "' and publicity_code=" + s4;
  69.                     String s10 = "UPDATE Budget_Master set budget_alloted=" + s5 + " where Branch='" + s3 + "' and publicity_code=" + s4;
  70.                     //datasource = "jdbc:odbc:budget";
  71.                     con = DriverManager.getConnection("jdbc:mysql://localhost:3306/publicity_db","db_user","test");
  72.                     int i = con.getTransactionIsolation();
  73.                     con.setTransactionIsolation(2);
  74.                     con.setAutoCommit(false);
  75.                     if("new".equalsIgnoreCase(s2))
  76.                     {
  77.                         PreparedStatement preparedstatement = con.prepareStatement(s8);
  78.                         preparedstatement.setString(1, s3);
  79.                         preparedstatement.setString(2, s4);
  80.                         preparedstatement.setString(3, s5);
  81.                         preparedstatement.setString(4, s7);
  82.                         preparedstatement.setString(5, s6);
  83.                         preparedstatement.executeUpdate();
  84.                         con.commit();
  85.                         preparedstatement.close();
  86.                     }
  87.                     if("update".equalsIgnoreCase(s2))
  88.                     {
  89.                         Statement statement = con.createStatement();
  90.                         statement.executeUpdate(s9);
  91.                         statement.executeUpdate(s10);
  92.                         con.commit();
  93.                     }
  94.                     con.setTransactionIsolation(2);
  95.  
  96.  
  97.                     con.close();
  98.                 }
  99.                 catch(SQLException sqlexception)
  100.                 {
  101.                     cleanUp();
  102.                     printSQLException(sqlexception);
  103.                 }
  104.                 out.flush();
  105.  
  106.                 return(mapping.findForward("bdgm"));
  107.  
  108.             }
  109.  
  110.  
  111.                 static void printSQLException(SQLException sqlexception)
  112.                 throws IOException
  113.             {
  114.                 System.out.print("<b>SQLException</b>\n<p>\n\n");
  115.                 for(; sqlexception != null; sqlexception = sqlexception.getNextException())
  116.                 {
  117.                     System.out.println("<b>SQLState:</b> " + sqlexception.getSQLState() + "<br>\n");
  118.                     System.out.println("<b>Message:</b> " + sqlexception.getMessage() + "<br>\n");
  119.                     System.out.println("<b>Vendor:</b> " + sqlexception.getErrorCode() + "<br>\n");
  120.                 }
  121.  
  122.             }
  123.  
  124.             String link(String s, String s1)
  125.             {
  126.                 return "<a href=\"" + s + "\">" + s1 + "</a>";
  127.             }
  128.  
  129.  
  130.             public void cleanUp()
  131.                 throws IOException
  132.             {
  133.                 if(con != null)
  134.                     try
  135.                     {
  136.                         out.print("Closing database connection");
  137.                         con.setTransactionIsolation(0);
  138.                         con.close();
  139.                         return;
  140.                     }
  141.                     catch(SQLException _ex)
  142.                     {
  143.                         return;
  144.                     }
  145.                 else
  146.  
  147.                    return;
  148.  
  149.  
  150.  
  151.  
  152.     }
  153.  
  154.  
  155. }
  156.  
  157.  
addbdgt.jsp(the first page where i enter the records)

[HTML]
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-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="Microsoft FrontPage 3.0">
<SCRIPT LANGUAGE="JavaScript" SRC="bscript.js"></SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body topmargin="0" leftmargin="0" bgproperties="fixed">
<div align="left">
<form name="arch" method="get" action="/BdgMastAction.do">
<table border="0" width="100%">
<tr>
<td width="100%" bgcolor="#DFDFFF" background="images/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"><strong><small><font face="Verdana"></font></small></strong></td>
<td width="50%" height="34"></td>
</tr>
<tr>
<td valign="top" width="50%" height="27"><strong><small><font 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">Delhi</option>
<option value="Ahmedabad">Ahmedabad</option>
<option value="Madras">Madras</option>
<option value="Bangalore">Bangalore</option>
<option value="Calcutta">Calcutta</option>
<option value="Hyderabad">Hyderabad</option>
<option value="Pune">Pune</option>
<option value="Lucknow">Lucknow</option>
<option value="Jaipur">Jaipur</option>
<option value="Patna">Patna</option>
<option value="Cochin">Cochin</option>
<option value="Chandigarh">Chandigarh</option>
<option value="Bhopal">Bhopal</option>
</select></p>
</td>
</tr>
<tr>
<td width="50%" height="25"><strong><small><font face="Verdana">Publicity Code </font></small></strong></td>
<td width="50%" height="25"><input type="text" size="5" maxlength="5"
name="publicity_code"></td>
</tr>
<tr>
<td width="50%" height="25"><strong><small><font face="Verdana">Annual Budget Alloted (<em>Rs</em>)</font></small></strong></td>
<td width="50%" height="25"><input type="text" size="10" maxlength="10" name="budget"></td>
</tr>
</table>
</div>

<p align="left"><input type="button" name="thesubmit" value="Submit"
onclick="everything(form)">&nbsp; </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="BdgtMasForm"

type="publicity.BdgtMasForm"/>

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

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

path="/index"

type="org.apache.struts.actions.ForwardAction"

parameter="/index.jsp"/>

<action

path="/bdgm"

type="org.apache.struts.actions.ForwardAction"

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

<action

path="/addbdgt"

type="org.apache.struts.actions.ForwardAction"

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



<action

path="/BdgMastAction"

type="publicity.BdgMastAction"

name="BdgtMasForm"

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
Sep 10 '07 #1
Share this Question
Share on Google+
8 Replies


10K+
P: 13,264
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.
Sep 10 '07 #2

100+
P: 283
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
Sep 10 '07 #3

10K+
P: 13,264
hi r035198x,
....this page is working fine if i use servlets and jsp's...
So when did you say it's not working?
Sep 10 '07 #4

100+
P: 283
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.do

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

type Status report

message /BdgMastAction.do

description The requested resource (/BdgMastAction.do) 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??
Sep 10 '07 #5

10K+
P: 13,264
.. 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.
Sep 10 '07 #6

100+
P: 283
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
Sep 10 '07 #7

10K+
P: 13,264
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
Sep 10 '07 #8

100+
P: 283
hi frnds,
is ther anybdy who can help me in this regard(struts).....plz help guyz.......
regards,
ajos
Sep 11 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.