tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rudid...@xs4all.nl
Subject RE: String added to session in servlet not available in jsp
Date Thu, 09 Oct 2003 15:18:32 GMT
Sorry, not entirely sure what you meant.

I have copied your code and placed it in my servlet as follows:

        HttpSession session = request.getSession(true);
        String username = ( request.getParameter("username") != null ?
        request.getParameter("username") : "" ) ;
        session.setAttribute("usr", username);


my jsp now looks like this:

  String username = ( request.getParameter("usr") != null ?
  request.getParameter("usr") : "" ) ;
  session.setAttribute("usr", username);

  String usr = (String)session.getAttribute("usr");

Could you please tell me if this is what you meant?

> And how you get the session in your JSP??
> Try this
>
>  HttpSession session = request.getSession(true);
>  String username = ( request.getParameter("username") != null ?
> request.getParameter("username") : "" ) ;
>  session.setAttribute("usr", username);
>
> Sincerely
> Lic. Computer Science
> Erlis Vidal Santos
>
>
>> -----Original Message-----
>> From: rudidoku@xs4all.nl [mailto:rudidoku@xs4all.nl]
>> Sent: Thursday, October 09, 2003 10:54 AM
>> To: Tomcat Users List
>> Subject: RE: String added to session in servlet not available in jsp
>>
>>
>> > Can you please show how are you creating the session object???
>> No worries, here it is:
>>         HttpSession session = request.getSession(true);
>>         session.setAttribute("usr", request.getParameter("username"));
>>
>>
>> > Sincerely
>> > Lic. Computer Science
>> > Erlis Vidal Santos
>> >
>> > -----Original Message-----
>> > From: rudidoku@xs4all.nl [mailto:rudidoku@xs4all.nl]
>> > Sent: Thursday, October 09, 2003 10:44 AM
>> > To: tomcat-user@jakarta.apache.org
>> > Subject: String added to session in servlet not available in jsp
>> >
>> > Hi,
>> >
>> > I created a session object and added a string (username) to it.
>> > Systemout.println shows the username from the request. My
>> page is then
>> > forwarded to another as follows:
>> >
>> >         RequestDispatcher disp = ctx.getRequestDispatcher(target);
>> >         disp.forward(request, response);
>> >
>> > On this jsp page, I have teh following code:
>> >
>> >   String usr = (String)session.getAttribute("usr");
>> >   out.println("User: " + usr + "!");
>> >   out.println("Session Id:  " + session.getId());
>> >
>> > The page displays the session Id but not the usr.
>> >
>> > I'm quite baffled at why this is the case.
>> >
>> > looking in google for similar problems, but any help would be much
>> > appreciated!
>> >
>> > Rudi
>> >
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>> >
>> >
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>> >
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message