473,238 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,238 software developers and data experts.

Http status 404 error in struts!!

283 100+
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
8 12671
r035198x
13,262 8TB
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
ajos
283 100+
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
r035198x
13,262 8TB
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
ajos
283 100+
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
r035198x
13,262 8TB
.. 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
ajos
283 100+
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
r035198x
13,262 8TB
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
ajos
283 100+
hi frnds,
is ther anybdy who can help me in this regard(struts).....plz help guyz.......
regards,
ajos
Sep 11 '07 #9

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

Similar topics

1
by: chris fink | last post by:
Hi, What are the appropriate HTTP Status Codes for the following: 1. XML is not well-formed (structure problem).... 2. XML is not valid (as per DTD/XSD/XDR).....missing req'd field, etc I...
0
by: George | last post by:
Hello, I'm running an ASPX application "WebApplication1" which consumes a web service (service1.asmx) hosted on a machine with IP (128.1.7.x) . The web service is located in the intranet. The...
6
by: Nick Horrocks | last post by:
I have set up a custom error page for 404 errors. However the HTTP status code returned is 302 followed by 200, this causes search engines not to remove old pages from their index. How can I...
5
by: rk325 | last post by:
Yes, I've seen many posts about this type of error, and none of the solutions people applied worked for me. So please read this one carefully and help me if you can. I have a web service...
1
by: jctwguy | last post by:
G'day all My pc is on a domain and I have a test server in a work group. all the web application and the web service are working fine locally, but when I copy the project using service extension...
1
by: google | last post by:
I'm building a small ASPX page in C# to forward HTTP POST requests to another site. When the other site returns an HTTP error such as 404 or 405, I want to return that same HTTP status value to my...
1
by: kommaraju | last post by:
iam a starter to db2 & jdbc.i have a servlet program which connects to ibm db2 using jdbc.when i run this using apache tomcat 4.1.34 , it is showing a error message of HTTP STATUS 500 my jdbc...
11
by: jjw92 | last post by:
I've been banging my head against the wall with this one for a couple days so I'm hoping someone has some ideas. I have a web service that I created that is called by a .NET class library (which in...
0
by: Jazz Tan | last post by:
Good day, i had face some problem that taking me so much of time to think about it. can any one help me find out the solution?? thank in advance. below is the page message that i can...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.