This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes jsp-servletListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp-servletListener" Watch "jsp-servletListener" New topic
Author

jsp-servletListener

Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121
Hi to all,
I have I problem: I construct for the first time HttpBindingListiner; valueBound, for input data from database into session on

witch will occure in someJsp.jsp. But to get file from database I need an information about that particular user witch for who session is; like user_id - to make some query. So I need somehow to forward that information in valeBound, because that information must be ready before session is created.
In jsp:

I had try with setRequest, but I cant getRequest from valueBound, because it must be called from doPost, and when I put doPost, then Listeners wont work inside it.

Plese help
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I can't see the relation between getSession and a BindingListener...
Maybe you're looking for HttpSessionListener instead.


[My Blog]
All roads lead to JavaRanch
Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121
We are talking about HttpSessionBindingListiner, who is triggered on create session(valueBound) and on destroy session(valueUnbound)
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Marko Debac, if I am not wrong, you want to execute some code before session(valueBound). Am I right?


My blood is tested +ve for Java.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
Actually, the SessionBindingListener is fired when an object is put into session, not when a session is created.

User user = new User("Bob");
session.setAttribute("user", user);

At this point a SessionBindingEvent would get fired on the "user" object.

Your User object is what implements the interface so you would have

Kaveriappa Poonacha
Greenhorn

Joined: Feb 15, 2006
Posts: 10
if I've got your question right: you want to authenticate the user & have the login info before anything else.
authenticate the user making the request by any of the four authentication methods:
Basic authentication.
Client Certificate authentication.
Digest authentication.
Form authentication.

Once the user authenticated you can obtain the login of the user from the request object:
java.lang.String httpServletRequest.getRemoteUser().
There is more to Java security, authentication / authorization; have barely scratched the surface n you've set me on the trail. have experimented with Basic and Form authentication.
am requesting the ranch rangers to suggest resources n hard books to start off with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp-servletListener
 
Similar Threads
Doubt regarding Listeners
Session created
HFJS - final mock - q55
405 error
Questions about session tracking