views:

95

answers:

3

I have developed a java 1.4 web application.Application is deployed on jboss(tomcat).

suppose my folder structure is

   mainfolder(contains subfolders and jsp pages)
        images(contains all of images files)
        headerfiles(header files)
        javascript(javascript files)

url for website login page is

     mywebsite.com/mainfolder/login.jsp

if user types complete url for some static resource

     mywebsite.com/mainfolder/images/myimage.jpeg

then he can view image on this url.

I want to stop user to view these resources.What should i do?

is there way some way to specigy pattern of file names which i dont want user to see. In that case i can specify *.ssi pattern to hide.

+3  A: 

If those images are used in your pages, the user will HAVE TO be able to download them to see them.

This is basic HTTP. If you want to download a resource, you need to have access to it.

Preventing your users from accessing mywebsite.com/mainfolder/images/myimage.jpeg will mean you WON'T be able to use this image in your HTML or CSS.

If those files should not be available to the user but only the server, don't publish them by keeping them in a non-published folder.

Vincent Robert
can u please tell me how to keep those files in non published folder.what is difference between non published and published folder?Thanks
Maddy.Shik
A published resource is accessible through the web server, a non-published isn't.
Andreas_D
how to make non published folder?can u please refer me to some link for detail?i ma not able to find one.
Maddy.Shik
+1  A: 

Anything put under the webapp's WEB-INF directory cannot be directly accessed by the browser.

skaffman
if i put all of folders containing images,javascript etc?i will have to change change references to these resources which is in terms of thousands.like in case of javascript<script type="text/JavaScript" src="javascript/generic.js"></script>reference is specified relative to mainfolder.but now javascript folder no longer exist in mainfolder.So where should i make change.contextroot of my application is "/".Thanks
Maddy.Shik
If you put things under `WEB-INF`, then the browser can't see them. That's what you asked for. Either you want the browser to see these resources, or you don't.
skaffman
i dont want user to directly see those resources.But jsp pages should refer those resources.Otherwise i dont have any use for those resources.
Maddy.Shik
i think if i put resources in web-inf then i will not be able to access resourecs from jsp.because in jsps these resources are refered by url.
Maddy.Shik
A: 

I want to stop user to view these resources. What should i do?

Honestly, this makes no utter sense. How would the client ever be able to get the static data? You can put those files in /WEB-INF (a non-published folder) to hide them from direct access, but you can never use them in your JSP pages, simply because the client isn't able anymore to directly access it.

I think the biggest misconseption here is that you didn't realize that every image, CSS file, JS file, etc counts each as a fully independent HTTP request. It is not true that the complete website is been hauled by a single HTTP request.

BalusC