tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Henrique Alves Lima <email_danie...@yahoo.com.br>
Subject Re: Http Session Null issue
Date Fri, 03 Jul 2009 15:59:02 GMT
	How can the session been null if you're calling request.getSession() ? 

"(...) Returns the current session associated with this request, or if
the request does not have a session, creates one. (...)"

http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/http/HttpServletRequest.html#getSession()


	
	Maybe, you're getting a new session every time you're calling this page
and "settings" reference is getting null. I *think* this can happen if:

	- Something is invalidating the session before request.getSession get
called;
	- Your http client don't support cookies or is not sending the same
cookie every time;
	- URL rewriting is disabled.


	Look the value returned by request.getRequestedSessionId() or
session.getId(). If the same user call this page a lot of times, the
same id should be returned. 
	The best approach is look this value (session id) right before
session.setAttribute(ATTR_NAME, settings) and
session.getAttribute(ATTR_NAME) have been called.



On Fri, 2009-07-03 at 12:35 -0300, Daniel Henrique Alves Lima wrote:
> Hi, Achal.
> 
> 
> On Fri, 2009-07-03 at 19:48 +0530, Achal Patel wrote:
> > Its basically below:
> > 
> > HttpSession session = request.getSession();
> > Settings settings = (Settings) session.getAttribute(ATTR_NAME);
> > 
> > I debugged it and got to know that session is getting null and again
> > invoking the same resource from UI serves fine.
> > The same is working fine on Weblogic.
> 
> Am i missing something or you're saying that when session is null
> "(Settings) session.getAttribute(ATTR_NAME)" works ?
> Are you sure ? 
> 
> Or you're saying that, at Weblogic, request.getSession() is returning a
> non-null value AND "(Settings) session.getAttribute(ATTR_NAME)" is
> working ?
> 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
-- 
"If there must be trouble, let it be in my day, 
 that my child may have peace."

Thomas Paine


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message