permaculture playing cards*
The moose likes Servlets and the fly likes how tto initialize HttpServletRequest Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how tto initialize HttpServletRequest" Watch "how tto initialize HttpServletRequest" New topic
Author

how tto initialize HttpServletRequest

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
How can I obtain the reference of an HttpServletRequest within the sessionCreated-Method of HttpSessionListener?

something like:



This does not work:


Any Ideas?
[ September 08, 2008: Message edited by: nimo frey ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You can't directly initialize an HttpServletRequest. Why are you trying to? What is it you are trying to do?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
I want to get the methods available of HttpServletRequest.

I want to do something like:



Should I implement a method in my listener:



then I can call the global String ip in my sessionCreated-Method:



But this does not work..string is allways null.

any ideas?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

A session listener is designed to listen to session events. If you want to handle requests a Servlet is the tool you would normally use. If you want functionality accross all requests, a filter is a better choice.
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
As I use JSF and want avoid implementing Servlets directyl, I will try to use filters..

thanks.
 
jQuery in Action, 2nd edition
 
subject: how tto initialize HttpServletRequest
 
Similar Threads
How to test HttpSessionListener
doubt in filter
When the jsp contacts the servlet for the first time in a session
HttpSessionListener in Tomcat
Can we restrict number of sessions through configuration(web.xml).