Jsp
<%@ page language="java" import="[Link].*" pageEncoding="ISO-8859-
1"%>
<%
String path = [Link]();
String basePath =
[Link]()+"://"+[Link]()+":"+[Link]
Port()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP '[Link]' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="[Link]">
-->
</head>
<body>
This is my JSP page. <br><h:form
action="[Link] method="Post"
rendered="true" >
<br><br>Userid <input type="text" name="t1"> <br>
<br> pass
<input type="text"
name="t2"><br> <br>  
; &nbs
p; <input
type="submit" name="button1"value="submit"><br><br><br></h:form>
</body>
</html>
Servlet
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import Mypack.*;
import [Link].*;
public class Myservlet extends HttpServlet {
String s,s1,s2;
/**
* Constructor of the object.
*/
public Myservlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
[Link](); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method
equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
[Link]("text/html");
PrintWriter out = [Link]();
Connection con;
s=[Link]("t1");
s1=[Link]("t2");
Data d=new Data();
con=[Link]();
try
{
PreparedStatement ps=[Link]("select password
from user1 where username=? ");
[Link](1, s);
ResultSet rs=[Link]();
while([Link]())
{
s2=[Link](1);
}
}catch(SQLException x)
{
[Link](x);
}
if([Link](s2))
{
RequestDispatcher
rd=[Link]("/[Link]");
[Link](request, response);
}
else
{
RequestDispatcher
rd=[Link]("/[Link]");
[Link](request, response);
[Link]("user and password are invalid");
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
Data pacakage
package Mypack;
import [Link].*;
public class Data {
Connection con;
public Connection cc()
{
try
{
[Link]("[Link]");
con=[Link]("Jdbc:Odbc: stu");
}catch(ClassNotFoundException c)
{
[Link]();
}catch(SQLException s){
[Link]();
}
return con;
}
First jsp
<%@ page language="java" import="[Link].*" pageEncoding="ISO-8859-
1"%>
<%
String path = [Link]();
String basePath =
[Link]()+"://"+[Link]()+":"+[Link]
Port()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP '[Link]' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="[Link]">
-->
</head>
<body>
This is my JSP page. sucesssssssssss <br>
</body>
</html>