tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lightbulb432 <veerukrish...@hotmail.com>
Subject RE: HttpSession questions
Date Sun, 01 Jul 2007 20:37:48 GMT

I did notice the getServletContext() of the servlet classes, but in this case
the code is in a custom class that was forwarded to by the servlet - I don't
have access to the servlet in this class.

If however, I were to change my code and pass the return value of Servlet's
getServletContext() to my class, would a session still be created, as
happens using the request.getSession().getServletContext() approach?

Out of curiosity, why is there a getServletContext() on HttpSession? Pardon
my ignorance, but that just doesn't seem "right" - if it's there as
convenience, then shouldn't it be on the HttpServletRequest class as well?
If that's just the way it is, then that's fine... But is there some design
reason you can think of that the method is in the session but not request
object? Am I missing something here?




Caldarale, Charles R wrote:
> 
>> From: lightbulb432 [mailto:veerukrishnan@hotmail.com] 
>> Subject: HttpSession questions
>> 
>> Why is it that you need an HttpSession in order to get a 
>> ServletContext?
> 
> You don't - since your code is in a class that extends HttpServlet, just
> call getServletContext() directly; it's defined under
> javax.servlet.GenericServlet.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/HttpSession-questions-tf4008885.html#a11385434
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Mime
View raw message