Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

redirect all jsp to login page only

 
Sharad Raj
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a Web Application using struts 1.0, written almost 8 jsp. The problem is after starting application, when I change URL and provide /somejsp.jsp, instead of my start jsp it will lead to somejsp.jsp file, which is not required. I do not want to keep my jsp inside WEB-INF. Is there any way to modify application so that whenever user changes URL, it will lead to login page only, instead of /somejsp.jsp
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put a filter or interceptor on.

If the user is not logged in, redirect them to the login.

If they are logged in, and somejsp.jsp does not exist you could built a customer error page.

WP
 
Paul Clapham
Sheriff
Posts: 21124
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume that when you say "user changes URL", you mean that the user is going to the browser's address bar and modifying the URL visible there, right?

Well, the server has no way of knowing how the URL of a request was generated. Whether it was generated by the user clicking on a link or by the user typing in the address bar, the server can't tell.
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not want to keep my jsp inside WEB-INF.


We can be access them directly. Refer the following thread JSP's should Inside WEB-INF
 
Sharad Raj
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi William,

Yes, we can use interceptors or filters. Could you send me code please? Do I need to put code in web.xml and create a separate class?

Sharad
 
Sp Wong
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this is what you want?

Add this at the Struts-config.xml:



And your class file, it should be something below:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic