aspose file tools*
The moose likes JSP and the fly likes After logout application is opened using jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "After logout application is opened using jsp" Watch "After logout application is opened using jsp" New topic
Author

After logout application is opened using jsp

srinivas mallabathula
Greenhorn

Joined: Apr 12, 2011
Posts: 7
Hi,
I am developing one application using JSP and Spring. In this application,after click on 'Logout' it is redicted Login page.

Suppose this application URL is in following manner.
http://localhost:8080/test

After Logout the application,suppose I want to give following URL without giving any credentails.
http://localhost:8080/test/example.jsp

After this,application is opened.

I want to restrict this.How ?
thanks in advance

Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179

Suppose this application URL is in following manner.
http://localhost:8080/test

After Logout the application,suppose I want to give following URL without giving any credentails.
http://localhost:8080/test/example.jsp


It's not quite clear what you are asking for. But if it's about redirection at the time of logout, you can use sendRedirect() method of the response object to point you to the required page , in your case "example.jsp". Also if you want to stay on this page for some duration and then redirect , then you can use javascript to redirect you after some interval

Regards,
Vishal.


Programming is about thinking, NOT coding
srinivas mallabathula
Greenhorn

Joined: Apr 12, 2011
Posts: 7
After Logout the application,
If I give
http://localhost:8080/test/example.jsp
URL in browser address bar it can open the application.
But it has to remain in login page till enter credentials and press login button.

please follow attachments



[Thumbnail for 1.png]


[Thumbnail for 2.png]

[Thumbnail for 3.png]

Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179
hi,

You can do 1 thing. When you validate the user's login credentials, you put some data in session. Then in your jsp pages you check for that session variable, if that variable is not present you simply redirect it to the login page with some message. Thus the user will be restricted to opening any page without login . Also don't forget to invalidate() your session on logout.

I hope this is what you are looking for.

Regards,
Vishal
Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179
hi,

You can do 1 thing. When you validate the user's login credentials, you put some data in session. Then in your jsp pages you check for that session variable, if that variable is not present you simply redirect it to the login page with some message. Thus the user will be restricted to opening any page without login . Also don't forget to invalidate() your session on logout.

I hope this is what you are looking for.

Regards,
Vishal
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

all you need is to invalidate your session for the logged in user when he does a logout. :-)


http://plainoldjavaobject.blogspot.in
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: After logout application is opened using jsp