File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Bind User to session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Bind User to session " Watch "Bind User to session " New topic
Author

Bind User to session

Dalibor Ninkovic
Greenhorn

Joined: Oct 19, 2010
Posts: 2
I use form based authentication, and I want to bind User object to session. I don't know where I can create and set User as attribute if my form is directly passed to j_security_check? Should I use listener for that?

Are there any other sollutions for authentication? For example can I make my own form, pass it to my servlet, and make authentication somehow there? In that case should I change web.xml (login-config)?

David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Once the user has logged in, their username should be available on the request as getUserPrincipal
Dalibor Ninkovic
Greenhorn

Joined: Oct 19, 2010
Posts: 2
this helps only with one part of my problem, but thanks anyway. I need only once, right after authentication, to create User object and bind it. I can't in every servlet write same code for binding User into session. Maybe something like this stackoverflow example
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18129
    
    8

I haven't followed that link, but as soon as you think "I will have to do this for every servlet" you should start coding a servlet filter.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bind User to session
 
Similar Threads
Doubts about container managed authentication
logout security servlet
redirection on login
Form based authentication / Realms
designing login page