tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31090] New: - The session "disappears" when the context name contains the space character
Date Tue, 07 Sep 2004 13:55:00 GMT
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: tomcat-dev@jakarta.apache.org
        ReportedBy: erania@mail.bg


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: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message