• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resource Restriction using web.xml

 
PrachiS Shah
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a concern regarding the Form Based authentication in Java. I need to restrict the access of jsp pages to the user, until and unless he logs in. This is the code for that;

<web-resource-collection>
<url-pattern>*.jsp</url-pattern>
</web-resource-collection>

I have jsp pages in a folder called jsp, images in a folder called images and the css in the folder of css. When I apply the above restriction then the pages are not accessed and automatically it is redirected to the login page. This is the correct behavior that I want but the only issue is that my images and css also don't load. Hence my login page appears without css and images. Any help would be appreciated.
 
Manuel Schenkhuizen
Greenhorn
Posts: 14
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think you should show us what you write in your jsp .the <head> tag;
maybe the path of your css and images are not correct
perhaps a <interceptor> is a better solvement.
 
PrachiS Shah
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My head portion contains just links for the css and images files..Like,
For the css;
<link rel="stylesheet" type="text/css" href="css/utility/base.css"/>

For the images;
<img src="images/xyz.jpg" alt="XYZ" title="XYZ" />

The images and css folders are present in the WebContent itself
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page-relative URLs generally do not work in web apps. Use server-relative URLs that start with the context path. See the JSP FAQ for more information.
 
PrachiS Shah
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I give the context path? The context path is not going to be fixed.It depends upon the server on which it is deployed. All I need to do is to restrict the access of jsp pages till he logs in. I want to allow other resources i.e. images and css to be accessed anytime whether before of after login.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${pageContext.request.contextPath}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic