Hi All;
i am doing a small web application using
jsp and sqlserver 2000 using type 4 microsoft
jdbc driver.my code includes..
1. a simple "Login.jsp" with fields userid and email
<HTML>
<BODY bgcolor=gray>
<center>
<table>
<FORM METHOD=GET ACTION="LoginValidate.jsp">
<tr>
<td>UserId</td><td> <INPUT TYPE=TEXT NAME=username SIZE=20></td>
</tr>
<tr>
<td>E mail</td><td><INPUT TYPE=TEXT NAME=email SIZE=20></td>
</tr>
<tr>
<td><P><center><INPUT TYPE=SUBMIT value= "Click Me"></center>
</td>
</tr>
</FORM>
</table>
</center>
</BODY>
</HTML>
2. "LoginValidate.jsp" collecting data from "Login.jsp" print, putting them in session object and including another jsp "FromDb.jsp"
<html>
<body bgcolor=
coffee>
<center>
<b>Form se</b>
<br>
<br>
<%
String username=request.getParameter("username");
session.setAttribute( "sessuser", username);
String email=request.getParameter("email");
session.setAttribute( "sessmail", email );
%>
welcome
<br>
<br>
<br>
<table>
<tr><td>You are Mr----</td><td> <font color="navy"><%= username %></font></td>
</tr>
<tr>
<td>And Your E-mail id is----</td><td><U><font color=green><%= email %></font></u></td>
</table>
<br>
<br>
<br>
<br>
<br>
<jsp:include page="FromDb.jsp" />
</center>
</body>
</html>
3 "FromDb.jsp" here connecting to the databse and verify the userid and email as entered through Login.jsp in while(rs.next()) loop
<html>
<head><b>Database se</b></head>
<br><br>
<body>
<%@ page import="java.sql.*;" %>
<%
String uid="";
String mailid="";
String pwd="";
String UName="";
boolean b=false;
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost;DatabaseName=vendor","sa","sa");
Statement stmt=conn.createStatement();
String squery="select * from test1";
ResultSet rs=stmt.executeQuery(squery);
%>
<% while(rs.next())
{
uid=rs.getString("UserId");
mailid=rs.getString("email");
pwd=rs.getString("pass");
UName=rs.getString("UserName");
if(session.getAttribute( "sessuser").equals(uid) && session.getAttribute( "sessmail").equals(mailid))
{ %>
WELCOME Mr.<%= UName %>
<br>
And Your password is<br><br><font color=red> "<%= pwd %>"</font>
<% b=true; break; } } %>
<% if(b==false) { %>
<br>
<br>Sorry!!!<br><br>
You are not a Registered User.
<a href="register.jsp">Please Register</a>
<% } %>
</body>
</html>
<br>
<br>
<br>
<table>
<tr><td>You are Mr----</td><td> <font color="navy"><%= username %></font></td>
</tr>
<tr>
<td>And Your E-mail id is----</td><td><U><font color=green><%= email %> </font></u></td>
</table>
<br>
<br>
<br>
<br>
<br>
<jsp:include page="FromDb.jsp" />
</center>
</body>
</html>
...and the problem with the first if statement
if(session.getAttribute( "sessuser").equals(uid) && session.getAttribute( "sessmail").equals(mailid))
not executed and control always reaches to 2nd if statement but this code works fine with MS-access databse..Please let me know where i am wrong..as you people always help me...please reply soon.i am learning
java myself here is no one for help..ony ranchaers or sdn
[ September 12, 2006: Message edited by: Bear Bibeault ]