tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sameer" <skach...@srijansoft.com>
Subject Login Page
Date Fri, 24 Nov 2000 10:45:54 GMT
Hi everybody,

Following is the code for a login.jsp page developed in JRun. What changes
would be required to have the same page running in Tomcat Server.
Please help.....

<html>
<body bgcolor="#ffffff">
<%@
import="javax.servlet.*,javax.servlet.http.*,java.util.Date,java.text.DateFo
rmat,java.io.*,java.net.*,java.sql.*,com.livesoftware.jrun.plugins.jsp.JSPSe
ssion" %>

<%
HttpSession session = request.getSession(true);
%>

<%
int content_length=0;
String url = "jdbc:odbc:Booking";
Statement stmt = null;
String EmpIdAll = "";

try
{
 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 Connection con = DriverManager.getConnection(url, "", "");
 stmt = con.createStatement();
}
catch(java.lang.Exception e)
{
 out.println ("e:" +e);
}
%>

<%
int validated = 0;
String temp[] = new String[5];

  if (!Request.ServerVariables("Content_Length").equals(""))
  {
   content_length =
Integer.parseInt(Request.ServerVariables("Content_Length"));
  }

if (content_length > 0)
{
 try
 {
  String EmpPasswdAll = null;
  String EmpRolesAll = null;
  int flag = 0;
  ResultSet rsEmp = stmt.executeQuery("select UserId, Password, Roles from
Employee");
  while(rsEmp.next())
  {
   EmpIdAll = rsEmp.getString("UserId");
   EmpPasswdAll = rsEmp.getString("Password");
   EmpRolesAll = rsEmp.getString("Roles");

    if(EmpIdAll.equals(Request.Form("UserId")) &&
EmpPasswdAll.equals(Request.Form("Password")))
     {
       session.putValue("EmpId", ""+EmpIdAll);
       session.putValue("EmpRole", ""+EmpRolesAll);
       response.sendRedirect("contents.jsp");
     }
    else
     {
      flag = 1;
     }
  }
  if(flag == 1)
  {
   EmpIdAll = Request.Form("UserId");
   out.println("<center><font color=red><b> Incorrect login or password.
Please Login again. </b></font>");
  }

 }

 catch (SQLException ex)
 {
  out.println ("\n\n\n*** SQLException caught ***\n\n\n");
  out.println ("ex: " +ex);
 }
}
%>


<center>
<form name=login method=post action="login.jsp">

<table width=600 border=1 bgcolor="#dddddd">
<tr>
<td colspan=2 align=center>
<font size=+2 face=arial><b> Login Screen
</td>
</tr>
<tr>
<td>
<font size=2 face=arial><b> Employee Id
</td>
<td>
<input type=text size=10 name=UserId value="<%=EmpIdAll%>">
</td>
</tr>
<tr>
<td>
<font size=2 face=arial><b> Password
</td>
<td>
<input type=password size=10 name=Password>
</td>
</tr>
<tr>
<td align=center>
<input type="submit" value="Submit">
</td>
<td align=center>
<input type="reset" value="Reset">
</td>
</tr>
</table>

</form>
</body>
</html>


Thanks in anticipation,
Sameer



Mime
View raw message