This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes Auto Login with Container Managed Security Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Auto Login with Container Managed Security" Watch "Auto Login with Container Managed Security" New topic
Author

Auto Login with Container Managed Security

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
Some sites would store the user credential in cookie so that by sending the stored cookie, the user doesn't have to login again the next time. Javaranch and many BBS sites are examples. But, how can I implement such a feature if I also want to use container managed authentication?
Durgaprasad
Greenhorn

Joined: Oct 02, 2006
Posts: 17
I assume you are using HttpRequest, HttpResponse in your service method.

use the following code


to create a new cookie and store it in the client machine.

the life time of the cookie on the server machine depends on the age you set



I hope this will help you

scjp 91
scwcd perparing
Isdx preparing
Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
Thanks Durgaprasad,

But the point is how could I trigger the container's authentication mechanism by using cookies? Normally, I need to request a constrained page before being forwarded to the login page defined in web.xml and I have to post to j_security_check with proper j_username & j_password parameters. All these can't be invoked by cookies.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Durgaprasad,
Welcome to JavaRanch!

We're pleased to have you here with us in the servlets forum, but there
are a few rules that need to be followed, and one is that proper names are
required. Please take a look at the
JavaRanch Naming Policy and
adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Auto Login with Container Managed Security