Structure Query Language, C programming, Java, Servlet, Jsp, Unix

Thursday 12 April 2012

Assume that the information regarding the marks for all the subjects of a student in the last exam are available in a database, Develop a Servlet which takes the enrollment number of a student as a request parameter and displays the marksheet for the student.


[index.html]
<html>
<body>
<table align=center cellpadding=10>
<tr>
<td><img src="logo.jpg"/>
</table>
<form name="f1" action="pro16">

<table align="center">
<tr>
<td colspan=2><h2><i>SHOW YOUR RESULT</i></h2>
<tr>
<td>Enrollment Number:
<td><input type="text" name="eno">
<tr>
<td><input type="submit" value="Show Result">
<td><input type="reset" value="clear">
</table>
</form>
</body>
</html>

[pro16.java]


import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
@WebServlet("/pro16")
public class pro16 extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
try
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
int eno=Integer.parseInt(req.getParameter("eno"));
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","pankaj");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from result where eno="+eno);
out.println("<table align=center cellpadding=10><tr><td><img src=\"logo.jpg\"/></table>");
out.println("<table border=5 align=center><caption align=\"top\">STUDENT RESULT MARKSHEET</caption><tr><td><table cellpadding=5><tr><th>Enrollment No.<th>Name<th>Statistical Mathematics<th>Java<th>Sooadm<th>Operating System <tr>");
while(rs.next())
{
out.println("<td>" + rs.getInt("eno") + " <td>" +rs.getString("name") + "<td>" + rs.getInt("m_sm") + "<td>" + rs.getInt("m_java") + "<td>" + rs.getInt("m_sooadm") + "<td>" + rs.getInt("m_os"));
}
out.println("</table></table>");
}catch(Exception e){}
}
}

No comments:

Post a Comment