• 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

Resource Restriction using web.xml

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 14
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
${pageContext.request.contextPath}
 
I am Arthur, King of the Britons. And this is a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic