I am using Tomcat with Apache on Linux.  I have a working example of how

I solve the login problem using some slightly different constructs.  It
works quite well, so you may want to try it.  I save the user login name

as a session attribute and then determine that the attribute exists with

a non-null value before letting anyone in to any other screen except the

login screen.

---------------------------------------------------------------------------------

 <%@page language="java" import="java.util.*"%>
 <% boolean found = false;          // initialize variable
  String attr;
  Enumeration attributes = session.getAttributeNames();  // get all
attributes
  while (attributes.hasMoreElements()) { // loop through all attributes
   attr = (String) attributes.nextElement();
   if (attr.equals("CHTuser")) {
    String uName = (String) session.getAttribute("CHTuser"); // find
user name
     if (uName.length()>0) {   // proper entrance
      found = true;
     }
     break;           // terminate the loop
   }
  }
  if (!found) {            // improper entrance => send to login
 %>
   <jsp:forward page="CHT_Login.jsp?status=improper" />
 <% } %>


------------------------------------------------------------------------------------

> Hi everyone
> This is the third time I send this question with no answers.
> Please help...
>
>
> I have the following code:
>
> This is the main page
> // if login successfully
> session.invalidate();    // invalidate previous session
> session =3D request.getSession(true);    // create session
> session.setAttribute("loginName", loginName);    // put the login ID
> session.setMaxInactiveInterval(900);
> On the secondPage.jsp I have:
> <%
>   if (session.getValue("loginName")==null)
>   response.sendRedirect(response.encodeURL("error.html"));
> %>
>
>

--
Ivan Handler
Networking for Democracy
[EMAIL PROTECTED]

===========================================================================
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

Reply via email to