Solved

noob j_security_check question.

Posted on 2007-04-04
7
440 Views
Last Modified: 2008-03-03
1. to login, i use j_security_check... but what a bout logout?
2. If i wanted to keep track on which user login at what time, how do i insert the code in j_security_check so that it will do so?

0
Comment
Question by:InNoCenT_Ch1ld
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 18855335
Oddly, logout doesn't really have a definition.

What we do is clear all the session attributes, clear the cookies, and destroy the session.  It has the desired effect.

You can't insert code into j_security_check -- it's entirely internal to Tomcat and has no public interface.

What you have to do is add code to your login handling to set data in a database, or sessions, or wherever you keep data, to keep track of your users.  We log it to a database, for example.

0
 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 18855371
but if i define the action to be the j_security_check already, where am i suppose to add my code to?
0
 
LVL 27

Accepted Solution

by:
mrcoffee365 earned 500 total points
ID: 18855510
You post to j_security_check, you never see the actual j_security_check code itself.

In your web.xml, you define the name of the page for login, and for an error in login.  The login page is just the presentation of the username/password form to the user, which is in a special location in your webapp (jsp/security/protected).   You can create cookies there, if that helps your app.

This page has a simple walk-through of how to set up form-based authentication in Tomcat:
http://www.onjava.com/lpt/a/1024

This is a more complex discussion of it:
http://www.devx.com/assets/download/6264.pdf

This one is a little easier to follow and has a nice diagram of the typical web app page setup with Tomcat login, a login page, and the login-protected web-app pages:
http://www.javapassion.com/j2ee/WebApplicationSecurity.pdf
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 18855526
tks
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 18855540
You're welcome.

This is an area everyone has to work through, and there are a few different ways to use the login feature from Tomcat.  Post another question back on EE if you get stuck again.

Good luck!
0
 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 18855559
i'm using jdbcrealm with digest.. but i cant get it to work. if you know how, let me know, i will open a question.
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 18857862
I haven't used it, but I've used login with Tomcat a lot, and I'm sure there are other people at EE with specific jdbc realm and digested password experience.  So sure, post the question.

When you do, it would help a lot if you posted the jdbc realm definition in your server.xml, the security parts of your web.xml, the login code you're trying to make work, and the error message you're getting.  Obfuscate any parts of the code you need to -- although I don't think that any of this should be an issue, unless IP addresses are involved somewhere.
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question