Elena Palanca wrote:
>
> Hi,
> I hope someone could help me in this problem.
> I have a jsp page  for the login of the user. The page contains 2
> textbox the userid and password. After the user fill this form the jsp
> call the servlet AccessBean in this way:
> <form action="http://localhost:8080/examples/servlet/AccessBean"
> method="GET">
> The AccessBean servlet, check if the user is enabled to enter in the
> system and if yes, it create a session for him and write some
> information in a Bean as follows:
>          HttpSession session = req.getSession(true);
>         WomanJSP.LoginBean Login = null;
>          Login = (WomanJSP.LoginBean)
> java.beans.Beans.instantiate(getClass().getClassLoader(),"WomanJSP.LoginBean");
>
>          Login.setUserID(user);
>          Login.setPassword(pass);
>          Login.setProfile(prof1);
>          Login.setLevel(level);
>          Login.setSessionId(ide);
>          session.setMaxInactiveInterval(10800);
>          session.putValue("Login",Login);
>
> After this the servlet call a Jsp page that give a customized  menu with
> this code:
>
> 
>getServletContext().getRequestDispatcher("/jsp/WomanJSP/MenumedBean.jsp").forward(req,
> res);
>
> At this point I believe that all the data of the session are stored in
> the bean, the JSP will access the bean with scope "session" and I think
> it will see
> only data belonging to the session associate with the request it
> received.
> After this the jsp depending on the choices of the menu will call
> another JSP, and in this moment I loose all data stored in the bean.
> This last Jsp should pass data to another servlet but at this point it
> seem that the session was expired.
> What's happened? With this scheme do I really could maintain my sessions
> or I'm doing something wrong? I'm using startserver from JSP1.0
> specification.
> I cannot use Cookies use for my project.

I assume that the MenumedBean.jsp creates a menu like:

  <LI><A HREF=/jsp/WomanJSP/Function1.jsp>Function1</A>
  <LI><A HREF=/jsp/WomanJSP/Function2.jsp>Function2</A>
  <LI><A HREF=/jsp/WomanJSP/Function2.jsp>Function3</A>

Since you say you can't use Cookies you must instead use URL rewriting
for session tracking. This means that when you create your A HREF tags
you must encode the URLs with the HttpResponse.encodeURL method, so
that the servlet can add the session ID to the URL. The result should
look like:

  <LI><A HREF=/jsp/WomanJSP/Function1.jsp;$sessionid$1234>Function1</A>
  <LI><A HREF=/jsp/WomanJSP/Function2.jsp;$sessionid$1234>Function2</A>
  <LI><A HREF=/jsp/WomanJSP/Function2.jsp;$sessionid$1234>Function3</A>


--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to