Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to restrict direct accessing .jsp and .do in struts webapp

 
vamsi kris
Greenhorn
Posts: 28
Hibernate jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me

I need to restrict the user from accessing the jsp pages and .do directly ie through url and redirect him to the index page

 
vivek mahajan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use filter for that which will be monitoring for *.do pages it is the simplest and easiest way
 
Mahesh Lohi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vivek mahajan wrote:You can use filter for that which will be monitoring for *.do pages it is the simplest and easiest way


More details please.

I am new to java and jsp.

 
vivek mahajan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Filter are special java class which get called on the mapped resource. You don't need to call them. If you have configured any filter on *.do file then firstly the filter associated with it will be called in which you can do the appropriate coding for handling the request. For more details visit this
 
Kartik Tal
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope you are asking in such a way like there are 2 roles like "Admin" and "User"
Where user is not supposed to access all the pages.

In that case while you authenticate the person who logins into the application, keep the role in session.
And in jsp you can write logic of "IF" condition. And in condition check the role whether its User or Admin, if its user dont display the link but in Admin it has to show.

Post if you needed any brief information about this like which struts are you using and etc.....
 
vamsi kris
Greenhorn
Posts: 28
Hibernate jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI all,

thanks all for your support.

I am using a request processor (Controller) in struts to force login the user.
But I need to restrict the direct acess of urls as the user need to fill some data in the first page of application.
So i need to redirect the url to index page as soon as a user logged in.

can some one explain more about the filter class how to map forward to index page

Thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic