File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

After logout application is opened using jsp

 
srinivas mallabathula
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 179
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
srinivas mallabathula
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
1.png
Login screen
[Thumbnail for 1.png]
2.png
unauthorised URL enter in address bar
[Thumbnail for 2.png]
3.png
[Thumbnail for 3.png]
 
Vishal Shaw
Ranch Hand
Posts: 179
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 179
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 384
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all you need is to invalidate your session for the logged in user when he does a logout. :-)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic