Passing objects around different jsp/servlets using Session!

Discussions

Web tier: servlets, JSP, Web frameworks: Passing objects around different jsp/servlets using Session!

  1. I want to temporarily store objects so that it is available for use by other jsp/servlet pages.

    PAGE4.JSP
    <%@ page session="true" %>
    <%
    String s = "yes";
    session.setAttribute("isLogged", s);
    %>
    hyperlink to page10.jsp

    PAGE10.JSP
    state=
    <%
    String s = (String)session.getAttribute("isLogged");
    %>
    <%= s %>

    I am not able to pass around the variables around in the session. PAGE10.JSP displays nothing(null) instead of "yes". Do you have any ideas?

    Thanks,
    Roop.

  2. Yep if you want to pass session from a JSP to Servlet, it gets terminated. It is actually a JSP spec problem and when you try to pass it through a SUBMIT button particularly.

    In case you are using SUBMIT, convert that into a BUTTON and add a Javascript which includes the submit method and
    call the Servlet.It will get passed.

    Good Luck.

    Prasath

    bp8475 at sbc dot com or prasathb at yahoo dot com

    This I found out after struggling for more than 15 days.If you further have session terminating problem, write to me. I will help you out, but during the weekends
  3. Hi Roop,
            I am also facing the same problem in my site as u described here.Have u solved this problem if so pls
    tell me how did u do?
    thanks in advance
    Regards,
    Rama.
  4. go to the java forum in http://www.javaranch.com. its the best java forum i know of.

    goto serlvet/jsp. the topic for the thread is:Session Tracking using HttpSession. i had to fight for a week before i got things figured out.

    please reply to that thread in javaranch. i'm sure this will help.

    roop.
  5. Hi Roop,
         I read it. there url rewriting was mentioned but
    url rewriting is not secure. If we use it sessionid will
    be visible on the browser.
     Bye
    Rama