0

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, hallticket.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<TITLE> New Document </TITLE>

<META NAME="Generator" CONTENT="EditPlus">

<META NAME="Author" CONTENT="">

<META NAME="Keywords" CONTENT="">

<META NAME="Description" CONTENT="">

</HEAD>



<BODY bgcolor=blue>

<h1 align="center"><font color=red> Students Hall Ticketno</h1>

<form method="post" action="http:\\localhost:8080\results\marks">

<h3 align="center">Enter Hall Ticket No</h3>&nbsp;&nbsp;&nbsp

<center><input type="text" size=30><br><br>

<input type="submit" value="submit">

</BODY>

</HTML>

2. Ssc.java (servlet)
import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

import java.sql.*;

public class  	 Ssc extends HttpServlet

{

	Connection con=null;

	Statement st;

	ResultSet rs;

	public void init()

	{

		try

		{

		      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

               con = DriverManager.getConnection("jdbc:odbc:sravan","poorna","chandu");			

           st=con.createStatement();

			}

			catch( Exception e)

            {

			   e.printStackTrace();

            } 

	}

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException

		{

	try

	{

		String str=req.getParameter("htno");

		int htno=Integer.parseInt(str);

		String strq="select * from marks where htno="+htno;

		rs=st.executeQuery(strq);

		PrintWriter out=res.getWriter();

		if(rs.next())

		{

			out.println("<html><body>");

			out.println("<table border=1 align=center>");

			out.println("<tr><th>Name</th>");

			out.println("<th>Telugu</th>");

			out.println("<th>Hindi</th>");

			out.println("<th>English</th>");

			out.println("<th>Maths</th></tr>");

			out.println("<tr><td>"+rs.getString(3)+

				"</td><td>"+rs.getInt(4)+

				"</td><td>"+rs.getInt(5)+

				"</td><td>"+rs.getInt(6)+

				"</td><td>"+rs.getInt(7));

		}

	}

	catch (Exception e)

	{

		e.printStackTrace();

	}

		}

}

3,web.xml
<web-app>

<servlet>

<servlet-name>sscresults</servlet-name>

<servlet-class>Ssc</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>sscresults</servlet-name>

<url-pattern>/results</url-pattern>

</servlet-mapping>

</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

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by ~s.o.s~
0

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"> .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.