DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31090>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31090

The session "disappears" when the context name contains the space character

           Summary: The session "disappears" when the context name contains
                    the space character
           Product: Tomcat 5
           Version: Unknown
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Unknown
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Well, I am not quite sure it is a bug, but I lost one day to find where my
problem was, so it may be helpful :)
When the context name contains a space character (' ') everything works fine ,
except that the session object in the request is null (and a new session is
created when getSession is invoked ) even if a session has already been initialized.
For example:
public class MyServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
       doPost(request, response);
    }
    
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
      
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html><body><a href=\"MyServlet\"> click me!</a><br>");
        out.println(request.getSession().getAttribute("hello"));
        out.println("</body></html>");
        request.getSession().setAttribute("hello", "Hello!");
        
    }
}

When the context name contains a space (fo example: "Sample Project") and you
load the page and click on the link, the result is always :
click me
null

When you change the name to "SampleProject", the problem is gone.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to