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 JDBC and the fly likes How to determine user with Tomcat JDBC Realm 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 » Databases » JDBC
Bookmark "How to determine user with Tomcat JDBC Realm " Watch "How to determine user with Tomcat JDBC Realm " New topic
Author

How to determine user with Tomcat JDBC Realm

Doug Braidwood
Ranch Hand

Joined: Apr 04, 2010
Posts: 42
Hello there,

I am trying to write a little web application which will allow users to log in, and enter or retrieve data from a database.

I am using Tomcat and MySQL

It is basically working, my java components can talk to the database and I am using the JDBC realm in Tomcat for security. So I have a users and a user_roles table in the Database and Tomcat uses this to authenticate.

My question/problem is how to know which user has logged on. I would have thought this would be a session attribute but it doesn't seem to be.
Can you help?


SCJP, SCWCD
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 489
    
    5
Hi,

HttpServletRequest contains methods for programmatic security - getRemoteUser(), isUserInRole(), etc.
Doug Braidwood
Ranch Hand

Joined: Apr 04, 2010
Posts: 42
Thanks Karthik, that's exactly what I was looking for.
 
jQuery in Action, 2nd edition
 
subject: How to determine user with Tomcat JDBC Realm
 
Similar Threads
Multiple Realm Possible?
what is realm. ???
Tomcat with more than one Applications in WEBAPPS folder
question about user roles
question about tomcat JDBC realm.