| Author |
Resource Restriction using web.xml
|
PrachiS Shah
Greenhorn
Joined: Sep 02, 2010
Posts: 10
|
|
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
Joined: Apr 20, 2011
Posts: 14
|
|
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
Joined: Sep 02, 2010
Posts: 10
|
|
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
Joined: Jan 10, 2002
Posts: 56150
|
|
|
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.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
PrachiS Shah
Greenhorn
Joined: Sep 02, 2010
Posts: 10
|
|
|
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
Joined: Jan 10, 2002
Posts: 56150
|
|
|
${pageContext.request.contextPath}
|
 |
 |
|
|
subject: Resource Restriction using web.xml
|
|
|