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
- 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;
- }
- }
[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 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)"> </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