htttp status 404 error

Reply

Join Date: Mar 2008
Posts: 8
Reputation: madhusamala is an unknown quantity at this point 
Solved Threads: 1
madhusamala madhusamala is offline Offline
Newbie Poster

htttp status 404 error

 
0
  #1
Mar 8th, 2008
Actually i am doing a ssc project.
The student will enter his roll no in a web page which is designed by html.
HIs marks subject wise have to be displayed wth the total marks . this will be done by using servlets
and my html code is
  1. 1, hallticket.html
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  3.  
  4. <HTML>
  5.  
  6. <HEAD>
  7.  
  8. <TITLE> New Document </TITLE>
  9.  
  10. <META NAME="Generator" CONTENT="EditPlus">
  11.  
  12. <META NAME="Author" CONTENT="">
  13.  
  14. <META NAME="Keywords" CONTENT="">
  15.  
  16. <META NAME="Description" CONTENT="">
  17.  
  18. </HEAD>
  19.  
  20.  
  21.  
  22. <BODY bgcolor=blue>
  23.  
  24. <h1 align="center"><font color=red> Students Hall Ticketno</h1>
  25.  
  26. <form method="post" action="http:\\localhost:8080\results\marks">
  27.  
  28. <h3 align="center">Enter Hall Ticket No</h3>&nbsp;&nbsp;&nbsp
  29.  
  30. <center><input type="text" size=30><br><br>
  31.  
  32. <input type="submit" value="submit">
  33.  
  34. </BODY>
  35.  
  36. </HTML>
  37.  
  38. 2. Ssc.java (servlet)
  39. import java.io.*;
  40.  
  41. import javax.servlet.*;
  42.  
  43. import javax.servlet.http.*;
  44.  
  45. import java.sql.*;
  46.  
  47. public class Ssc extends HttpServlet
  48.  
  49. {
  50.  
  51. Connection con=null;
  52.  
  53. Statement st;
  54.  
  55. ResultSet rs;
  56.  
  57. public void init()
  58.  
  59. {
  60.  
  61. try
  62.  
  63. {
  64.  
  65. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  66.  
  67. con = DriverManager.getConnection("jdbc:odbc:sravan","poorna","chandu");
  68.  
  69. st=con.createStatement();
  70.  
  71. }
  72.  
  73. catch( Exception e)
  74.  
  75. {
  76.  
  77. e.printStackTrace();
  78.  
  79. }
  80.  
  81. }
  82.  
  83. public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
  84.  
  85. {
  86.  
  87. try
  88.  
  89. {
  90.  
  91. String str=req.getParameter("htno");
  92.  
  93. int htno=Integer.parseInt(str);
  94.  
  95. String strq="select * from marks where htno="+htno;
  96.  
  97. rs=st.executeQuery(strq);
  98.  
  99. PrintWriter out=res.getWriter();
  100.  
  101. if(rs.next())
  102.  
  103. {
  104.  
  105. out.println("<html><body>");
  106.  
  107. out.println("<table border=1 align=center>");
  108.  
  109. out.println("<tr><th>Name</th>");
  110.  
  111. out.println("<th>Telugu</th>");
  112.  
  113. out.println("<th>Hindi</th>");
  114.  
  115. out.println("<th>English</th>");
  116.  
  117. out.println("<th>Maths</th></tr>");
  118.  
  119. out.println("<tr><td>"+rs.getString(3)+
  120.  
  121. "</td><td>"+rs.getInt(4)+
  122.  
  123. "</td><td>"+rs.getInt(5)+
  124.  
  125. "</td><td>"+rs.getInt(6)+
  126.  
  127. "</td><td>"+rs.getInt(7));
  128.  
  129. }
  130.  
  131. }
  132.  
  133. catch (Exception e)
  134.  
  135. {
  136.  
  137. e.printStackTrace();
  138.  
  139. }
  140.  
  141. }
  142.  
  143. }
  144.  
  145. 3,web.xml
  146. <web-app>
  147.  
  148. <servlet>
  149.  
  150. <servlet-name>sscresults</servlet-name>
  151.  
  152. <servlet-class>Ssc</servlet-class>
  153.  
  154. </servlet>
  155.  
  156. <servlet-mapping>
  157.  
  158. <servlet-name>sscresults</servlet-name>
  159.  
  160. <url-pattern>/results</url-pattern>
  161.  
  162. </servlet-mapping>
  163.  
  164. </web-app>

Ihave copied this enter codes and classed in tomcat server webapps diirectory and the directory hierarchy is
----- !WEB-INF
--------------!classes --- Ssc.class
--------------!src ----Ssc.java
------!web.xml
------!hallticket.html (web page)
------!results (access data base)

in results database i have created one table with marks

rollno telugu hindi english maths social
112 95 98 98 98 98
113 98 98 98 98 98

LIKE THAT
When i run the tomcat server it is displaying the above file that hallticket.html and web.xml

when i deploy my project , when i enter the hall ticket no

it is giving an error http status 404 error
that the source /results/marks is not found .

Please help me , where did i commit the mistake
Thank you in advance
Last edited by ~s.o.s~; Mar 9th, 2008 at 6:36 am. Reason: Added code tags, learn to use them.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,614
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 466
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: htttp status 404 error

 
0
  #2
Mar 9th, 2008
The action attribute of your FORM tag should point to the servlet which would be doing all the processing. The servlet path can be obtained from the web.xml and is the same as the url-pattern for that servlet. In your case it should be <form action="results"> .
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC