This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes User Name and Basic authentication 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 » JSP
Bookmark "User Name and Basic authentication" Watch "User Name and Basic authentication" New topic
Author

User Name and Basic authentication

Mohan Panigrahi
Ranch Hand

Joined: Sep 28, 2001
Posts: 142
Hi Ranchers,
I am using basic authentication. The user enters correct user_id and password once, and as long his session does not expire, he remains "validated" to access the protected resources.

Now, in one of my JSPs/servlets,I want to get access the userId field for some database query. Does tomcat or other containers would store the user_id field (entered by user during authentication) somewhere in session, so that I can access it from JSP pages?

Thanks,
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
I think that HttpServletRequest.getUserPrincipal().getName() solves your problem.


Leandro Melo
SCJP 1.4, SCWCD 1.4
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: User Name and Basic authentication
 
Similar Threads
can not understand
Can we have multiple login forms in spring security?
Auth by DIGEST
JSR 196 and SAM questions
HttpSession and/or Container-managed authentication/authorization