Hi everyone,
I have a small JSP application which is password protected. After Authentication, I
am saving the userID and Password in JSP Session. Then any proceeding page, I check
to see if the session is alive or not.
It works perfect with Netscape but doesn't work in IE. Any help will be appreciated.
Thanks
Hassan Dasti
Sample Code Below:
In "validate.jsp" Page
<%@ page import="java.sql.*, java.util.*, cdis.beans.*, lib.beans.*" %>
<%@ page errorPage = "errorPage.jsp" %>
<%
HttpSession vSession = request.getSession(true);
%>
<html>
<body>
<%!
int flag = 0;
String dbId = "";
String dbPass = "";
String dbRole = "";
String dbDist = "";
String errmesg= "";
cdisValidateBean cdis = new cdisValidateBean();
Vector vec = new Vector();
%>
<%
String userPass = request.getParameter("password");
String userId = request.getParameter("ID");
try{
vec = cdis.getAllUserLogin();
Enumeration rs = vec.elements();
flag = 0;
while(rs.hasMoreElements() && (flag==0) )
{
dbId = rs.nextElement().toString();
dbPass = rs.nextElement().toString();
dbRole = rs.nextElement().toString();
dbDist = rs.nextElement().toString();
if(dbId.equals(userId) && dbPass.equals(userPass) )
{
flag = 1;
vSession.putValue("sesUserId", userId);
vSession.putValue("sesPasswd", userPass);
vSession.putValue("sesRole", dbRole);
vSession.putValue("sesDist", dbDist);
response.sendRedirect("cdisSearch.jsp");
}
}
if(flag == 0)
{
%> <CENTER><IMG alt="CDIS" border="0" src="images/cdisWO.jpg"><P>
<img src="images/invalid.jpg"><p>
<B>Please <a href="index.html">Click Here</a> and Try to Login
again.</B><P>
</center> <%
}
}catch(OAException ex ){
errmesg = "Error in getAllUserLogin() " + ex.getMessage();
vSession.putValue("errmsg", errmesg);
System.out.println("errmsg: "+ errmesg);
response.sendRedirect("errorInt.jsp");
}catch (Exception e){
errmesg = "Error in getAllUserLogin() " + e.getMessage();
vSession.putValue("errmsg", errmesg);
System.out.println("errmsg: "+ errmesg);
response.sendRedirect("errorInt.jsp");
}
%>
</body></html>
END of Validate.jsp Page
then In cdisSearch.jsp Page
<%@page import="java.sql.*, java.text.*, java.io.*, java.util.*, cdis.beans.*,
lib.beans.*" %>
<%
String dbrespass = "";
String dbresid = "";
String dbresrole = "";
String isFalse = "false";
HttpSession vSession = request.getSession(false);
try
{
if(!(vSession.isNew()))
{
dbresid = (String)vSession.getValue("sesUserId");
dbrespass = (String)vSession.getValue("sesPasswd");
dbresrole = (String)vSession.getValue("sesRole");
if( dbresid.equals(isFalse))
{ response.sendRedirect("errorInt.jsp?Res=NS");}
}
else { response.sendRedirect("errorInt.jsp?Res=NS"); }
}
catch(Exception e)
{
System.out.println("searchPersonal.jsp Exception");
out.println(e);
}
......
IN netscape I am taken to cdisSearch.jsp page without any problems but In I IE I am
redirected to my error Page called errorInt.jsp?Res=NS
Please let me know if some one has any suggestions.
Thanks again.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets