my dog learned polymorphism*
The moose likes JSP and the fly likes Referring Script outside WEB-INF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Referring Script outside WEB-INF" Watch "Referring Script outside WEB-INF" New topic
Author

Referring Script outside WEB-INF

Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
hi all,
below is my Project folder structure

contextroot/scripts/temp.js
contextroot/stylesheets/layoutStyles.css
contextroot/WEB-INF
contextroot/WEB-INF/JSP/temp.jsp

i tried to use the stylesheet in a temp.jsp page inside JSP folder,
i referred the stylesheet as


but it is not referred. the same case with the script file...
is there any problem in referring the source outside the WEB-INF.

Any pointers would appreciated...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I think that you should avoid relative paths,
and use absolute paths instead.
Like /scripts/temp.js


[My Blog]
All roads lead to JavaRanch
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Satou kurinosuke:
...
Like /scripts/temp.js


That won't work either.
The preceding slash tells the browser that this link is realative to the domain (the context path will be skipped).

Your best approach is to read the context path from the request object and then build your link; relative to that.

JSP.2.0:


Legacy:

[ July 13, 2006: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Referring Script outside WEB-INF
 
Similar Threads
CSS LInks issue
Do Not Understand "/tags/struts-logic" Not Found
problem with webapp directory structure
Calling JSP with in WEB-INF
Linkking css & js to jsp in struts