Hi,
Please try this source code
<%-- Document : as Created on :
Jul 26, 2008, 12:41:17 PM
Author : user1--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java"%>
<%@ page
import="java.sql.*,javax.sql.*,javax.naming.*,java.io.*,java.util.*"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String userid = request.getParameter("userid");
String password = request.getParameter("password");
InitialContext context = new InitialContext();
DataSource ds = (DataSource) context
.lookup("java:comp/env/jdbc/mynewdatabase");
Connection conn = ds.getConnection();
context.close();
ResultSet rs = null;
Statement stmt = null;
String groupId=null;
stmt = conn.createStatement();
try {
rs = stmt
.executeQuery("select groupid from user where emailid='"
+ userid + "' and Password='" + password + "'");
%>
<%
while (rs.next()) {
%>
<%
groupId = rs.getString("username");
out.println(groupId);
out.println("Invalid User");
}
} catch (Exception e) {
} finally {
if (stmt != null) {
stmt.close();
}
if (rs != null) {
rs.close();
}
if (conn != null)
conn.close();
}
if (groupId == null) {
%>
<jsp:forward page="/abc.jsp" />
<%
} else {
out.println("Valid User");
%>
<jsp:forward page="/try.jsp" />
<%
}
%>
</body>
</html>
Regards,
mohanasundaram