• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

redirect all jsp to login page only

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

reply
    Bookmark Topic Watch Topic
  • New Topic