You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Oscar Moreno <om...@prosrm.com> on 2000/07/14 14:56:59 UTC

RE: My parameters are lost when storing them in HttpSession using Servlet

If cookies are not supported, you should tried encoding your URLs with the
encodeURL() method of the HttpServletResponse interface.
 
I hope this helps.
 
Oscar

 -----Original Message-----
From: Andrew Shiels [mailto:shiels@ssi-schaefer-noell.com]
Sent: Friday, July 14, 2000 3:12 AM
To: tomcat-user@jakarta.apache.org
Subject: My parameters are lost when storing them in HttpSession using
Servlet 



I have a servlet which verifies user login information in a database. If the
user is allowed to login I add some information to the session object and
redirect the user to a start page:
 
public void doGet (HttpServletRequest req, HttpServletResponse res)
           throws ServletException, IOException
    {
..
..
  HttpSession session = req.getSession(true);
  session.setAttribute("loggedIn",  new String("true"));
  session.setAttribute("permission",  new Integer(iPermission));
  res.sendRedirect("index.jsp"); 
 
..
..
}
 
My problem is that when I try and access this session information in my
"index.jsp" page, all values are null.
 
<%@ page errorPage = "Error.jsp" import = "java.util.*,
javax.servlet.http.*, javax.servlet.*" %>
<HTML>
<HEAD>
<TITLE>KULIE</TITLE>
</HEAD>
..
<%=session.getAttribute("permission")%>
<%=session.getAttribute("loggedIn")%>

..
</HTML>
 
I have no idea what the problem is, and have stripped my code right down to
the bare bones to see if I am making any stupid mistake. 
 
Also, I have tested the following with  2 jsp pages, where 1 jsp page stores
data in the session, then redirects to another page where the data is
printed. The files are as follows:
 
v.jsp
 
<%session.setAttribute("andy", new String ("HELLO!"));%>
<% response.sendRedirect ("w.jsp");%>
 
w.jsp
 
<HTML>
<BODY>
<H1>
<%=session.getAttribute("andy")%>
</H1>
</BODY>
</HTML>
 
This works fine, so my problem only seems related to servlets. 
 
Has anyone any idea on what could possible be causing the problem?
 
Thanks,
 
Andy Shiels
 
 


Re: My parameters are lost when storing them in HttpSession using Servlet

Posted by Andrew Shiels <sh...@ssi-schaefer-noell.com>.
My form is written using Macromedia Shockwave flash, and I've discovered that the problem lies with Flash, and not my servlet. I've changed my form to a normal HTML form and everything works ok.

Thanks for replying anyway.

Andy
  ----- Original Message ----- 
  From: Oscar Moreno 
  To: 'tomcat-user@jakarta.apache.org' 
  Sent: Friday, July 14, 2000 2:56 PM
  Subject: RE: My parameters are lost when storing them in HttpSession using Servlet 


  If cookies are not supported, you should tried encoding your URLs with the encodeURL() method of the HttpServletResponse interface.

  I hope this helps.

  Oscar

   -----Original Message-----
  From: Andrew Shiels [mailto:shiels@ssi-schaefer-noell.com]
  Sent: Friday, July 14, 2000 3:12 AM
  To: tomcat-user@jakarta.apache.org
  Subject: My parameters are lost when storing them in HttpSession using Servlet 


    I have a servlet which verifies user login information in a database. If the user is allowed to login I add some information to the session object and redirect the user to a start page:

    public void doGet (HttpServletRequest req, HttpServletResponse res)
               throws ServletException, IOException
        {
    ..
    ..
      HttpSession session = req.getSession(true);
      session.setAttribute("loggedIn",  new String("true"));
      session.setAttribute("permission",  new Integer(iPermission));
      res.sendRedirect("index.jsp"); 

    ..
    ..
    }

    My problem is that when I try and access this session information in my "index.jsp" page, all values are null.

    <%@ page errorPage = "Error.jsp" import = "java.util.*, javax.servlet.http.*, javax.servlet.*" %>
    <HTML>
    <HEAD>
    <TITLE>KULIE</TITLE>
    </HEAD>
    ..
    <%=session.getAttribute("permission")%>
    <%=session.getAttribute("loggedIn")%>

    ..
    </HTML>

    I have no idea what the problem is, and have stripped my code right down to the bare bones to see if I am making any stupid mistake. 

    Also, I have tested the following with  2 jsp pages, where 1 jsp page stores data in the session, then redirects to another page where the data is printed. The files are as follows:

    v.jsp

    <%session.setAttribute("andy", new String ("HELLO!"));%>
    <% response.sendRedirect ("w.jsp");%>

    w.jsp

    <HTML>
    <BODY>
    <H1>
    <%=session.getAttribute("andy")%>
    </H1>
    </BODY>
    </HTML>

    This works fine, so my problem only seems related to servlets. 

    Has anyone any idea on what could possible be causing the problem?

    Thanks,

    Andy Shiels