Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Session Management using JSP

Reply
Thread Tools

Session Management using JSP

 
 
KK
Guest
Posts: n/a
 
      07-18-2008
Hello Everyone,


I have developed on small site...now i can able to login but i have
not maintain session to user logout. Please give small example JSP
with login screen & checking in all form to authorise user & logout
properly.

Hope you will help me


Thanking You in anticipation


Regards,

Kartikeya
 
Reply With Quote
 
 
 
 
Dave Miller
Guest
Posts: n/a
 
      07-18-2008
KK wrote:
> Hello Everyone,
>
>
> I have developed on small site...now i can able to login but i have
> not maintain session to user logout. Please give small example JSP
> with login screen & checking in all form to authorise user & logout
> properly.
>
> Hope you will help me
>
>
> Thanking You in anticipation
>
>
> Regards,
>
> Kartikeya


Set a cookie on login; read it for each authorization; destroy or null
its value for logout. If you want to give users the option to "remember
me on this computer", make your cookie(s) persistent.


--
Dave Miller
Java Web Hosting at:
http://www.cheap-jsp-hosting.com/
 
Reply With Quote
 
 
 
 
KK
Guest
Posts: n/a
 
      07-18-2008
Thanks for replying, but can you plz give me any example of this? i
dont knw how to make cookies also.

Thanking you


Kartikeya
 
Reply With Quote
 
KK
Guest
Posts: n/a
 
      07-18-2008
On Jul 18, 9:18*pm, KK <(E-Mail Removed)> wrote:
> Thanks for replying, but can you plz give me any example of this? i
> dont knw how to make cookies also.
>
> Thanking you
>
> Kartikeya


 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      07-18-2008
KK wrote:
> I have developed on small site...now i can able to login but i have
> not maintain session to user logout. Please give small example JSP
> with login screen & checking in all form to authorise user & logout
> properly.


The easiest is to use container managed security. You protect your
pages in web.xml, provide a login form and let the container
do all the work.

Arne
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      07-18-2008
Arne Vajh°j wrote:
> KK wrote:
>> I have developed on small site...now i can able to login but i have
>> not maintain session to user logout. Please give small example JSP
>> with login screen & checking in all form to authorise user & logout
>> properly.

>
> The easiest is to use container managed security. You protect your
> pages in web.xml, provide a login form and let the container
> do all the work.


And before you ask for an example:

http://courses.coreservlets.com/Cour...eclarative.pdf

Arne
 
Reply With Quote
 
Dave Miller
Guest
Posts: n/a
 
      07-18-2008
Arne Vajh°j wrote:
> KK wrote:
>> I have developed on small site...now i can able to login but i have
>> not maintain session to user logout. Please give small example JSP
>> with login screen & checking in all form to authorise user & logout
>> properly.

>
> The easiest is to use container managed security. You protect your
> pages in web.xml, provide a login form and let the container
> do all the work.
>
> Arne

The right way to do it may be via the container but if you have to learn
the tech before you use it, I'm not so sure on the easier part.

--
Dave Miller
Java Web Hosting at:
http://www.cheap-jsp-hosting.com/
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      07-18-2008
Dave Miller wrote:
> Arne Vajh°j wrote:
>> KK wrote:
>>> I have developed on small site...now i can able to login but i have
>>> not maintain session to user logout. Please give small example JSP
>>> with login screen & checking in all form to authorise user & logout
>>> properly.

>>
>> The easiest is to use container managed security. You protect your
>> pages in web.xml, provide a login form and let the container
>> do all the work.

> The right way to do it may be via the container but if you have to learn
> the tech before you use it, I'm not so sure on the easier part.


It is much easier than writing all the code yourself.

Arne
 
Reply With Quote
 
Dave Miller
Guest
Posts: n/a
 
      07-18-2008
KK wrote:
> Thanks for replying, but can you plz give me any example of this? i
> dont knw how to make cookies also.
>
> Thanking you
>
>
> Kartikeya


If you don't already have the rest of your login / security system
built, take arne's suggestion. If all you need to do is gain persistance
the API in javax.servlet.http.Cookie is pretty self explanatory. To
give you a jump start:

To set a cookie:

Cookie cookie = new Cookie(java.lang.String name, java.lang.String value);
// do stuff with cookie
response.addCookie(cookie);

To check for it coming back:

try{
if (request.getCookies() != null){
Cookie[] allCookies = request.getCookies();
for (int i=0; i<allCookies.length; i++) {
Cookie cookie = allCookies[i];
//get info from cookie

}catch ...
--
Dave Miller
Java Web Hosting at:
http://www.cheap-jsp-hosting.com/
 
Reply With Quote
 
KK
Guest
Posts: n/a
 
      07-19-2008
thanks for help..

actually i tried the container based security, both form and basic. In
form based security am having a small problem. As guided by the
example, i edited my web.xml and tomcat-users.xml file. but while
using FORM authentication it started restricting my whole web
application. i even checked the roles and users mentioned the both of
the xml files but still the problem persists.

onething i want to ask more is, when we create a login form in this,
we define the form action as "j_security_check" and similarly the
username and password, then how i will match the username and password
of the registered users which are present in the database? The
username and password of the registered users are stored in the
database as soon as they register.

am sorry i am troubling you a lot but am totally confused, plz help
me.

Thanking you,

Kartikeya
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Pass session parameters from one jsp to another jsp sridhar kumar ch Java 1 06-28-2006 05:28 PM
How to Pass session parameters from one jsp to another jsp sridhar kumar ch Java 0 06-28-2006 11:16 AM
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
JSP security-session management dina Java 1 09-09-2005 09:27 AM
Tomcat JSP session beans not being removed at the end of the session John Smith Java 2 07-15-2004 12:46 PM



Advertisments