JSP/session question

Discussion in 'Java' started by Michael, Jan 25, 2004.

  1. Michael

    Michael Guest

    Hej Alle!

    I'm trying to get this very simple jsp page to work under Tomcat 4.1.x (x=24
    and 27, with similar results):

    --------------------------
    <HTML>
    <HEAD>
    <TITLE>sessiontest.jsp</TITLE>
    </HEAD>
    <BODY>
    Current value of A is: <%= session.getAttribute("A") %><br>
    Now we set the value of A to "george"..<%
    session.setAttribute("A","george"); %>..done!<BR>
    <BR>
    Just to verify, here's A again: <%= session.getAttribute("A") %><BR>
    <BR>Now <A href="sessiontest.jsp">reload</A> the page.
    </BODY>
    </HTML>

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

    When I load the page, everything works as expected. A begins with a null
    value, is then set to "george" and this is verified in the last line of
    output.

    But when I click the link to reload the page, A once again starts as null.
    In other words, a new session is created each time the jsp page is loaded.

    I have run this exact page under WebSphere 5, and it appeasrs to work as
    intended - i.e. the second time the page is loaded, A is already initialized
    with "george".

    Can anyone tell me what is going on here? What am I doing wrong?

    (Please do not ask me to use jsp:useBean - the above is a simplified example
    of what I really want to do, which involves setting session attributes from
    inside custom tags etc. I really need to set the values using the session
    object).

    My IE cookie settings are normal, and I'm not using a proxy server.

    Mvh
    /Michael
    www.hyperpal.com
     
    Michael, Jan 25, 2004
    #1
    1. Advertising

  2. Michael

    Ryan Stewart Guest

    "Michael" <> wrote in message
    news:4013baab$0$95056$...
    > Hej Alle!
    >
    > I'm trying to get this very simple jsp page to work under Tomcat 4.1.x

    (x=24
    > and 27, with similar results):
    >
    > --------------------------
    > <HTML>
    > <HEAD>
    > <TITLE>sessiontest.jsp</TITLE>
    > </HEAD>
    > <BODY>
    > Current value of A is: <%= session.getAttribute("A") %><br>
    > Now we set the value of A to "george"..<%
    > session.setAttribute("A","george"); %>..done!<BR>
    > <BR>
    > Just to verify, here's A again: <%= session.getAttribute("A") %><BR>
    > <BR>Now <A href="sessiontest.jsp">reload</A> the page.
    > </BODY>
    > </HTML>
    >
    > --------------------------
    >
    > When I load the page, everything works as expected. A begins with a null
    > value, is then set to "george" and this is verified in the last line of
    > output.
    >
    > But when I click the link to reload the page, A once again starts as null.
    > In other words, a new session is created each time the jsp page is loaded.
    >
    > I have run this exact page under WebSphere 5, and it appeasrs to work as
    > intended - i.e. the second time the page is loaded, A is already

    initialized
    > with "george".
    >
    > Can anyone tell me what is going on here? What am I doing wrong?
    >
    > (Please do not ask me to use jsp:useBean - the above is a simplified

    example
    > of what I really want to do, which involves setting session attributes

    from
    > inside custom tags etc. I really need to set the values using the session
    > object).
    >
    > My IE cookie settings are normal, and I'm not using a proxy server.


    Works fine under Tomcat 5.0.16, and I use 4.0/4.1 frequently and haven't had
    that problem with them. I'm no Tomcat guru, but there may be a server
    setting that's been changed.
     
    Ryan Stewart, Jan 25, 2004
    #2
    1. Advertising

  3. Michael

    Michael Guest

    Hi,

    > Works fine under Tomcat 5.0.16, and I use 4.0/4.1 frequently and haven't

    had
    > that problem with them. I'm no Tomcat guru, but there may be a server
    > setting that's been changed.


    Could you verify if it actually does work under 4.1.24 for example?

    Also, the Tomcat installation is pretty much "out of the box" as far as
    server settings are concerned. Do you have any suggestions as for which
    settings could be affecting session behaviour?

    I guess I could just try it under 5.x and see what happens, but the problem
    is that my app must work in a hosted environment where I do not have total
    control over the software.

    /Michael
    www.hyperpal.com
     
    Michael, Jan 25, 2004
    #3
  4. Michael

    Michael Guest

    Re: JSP/session question - problem solved

    Hi all,

    Apparently Tomcat does not function properly with document context names
    containing blanks. After changing the webapp to use a simple one-word
    document root, everything worked.

    I guess I should have known better, but OTOH Tomcat should be able to handle
    context roots with blanks, if WebSphere can do it without problems.

    /Michael
     
    Michael, Jan 25, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Smith
    Replies:
    2
    Views:
    2,214
    Sampsa Sohlman
    Jul 15, 2004
  2. Replies:
    0
    Views:
    4,407
  3. sridhar kumar ch
    Replies:
    1
    Views:
    8,602
  4. sridhar kumar ch
    Replies:
    0
    Views:
    808
    sridhar kumar ch
    Jun 28, 2006
  5. zalek
    Replies:
    1
    Views:
    367
Loading...

Share This Page