Kit,
You're mixing up references and URLs here.
If your web app is at /test you can use JSP resource paths and move the app
and it will still work HOWEVER this will not work for URLs (which your
images are) because you are hardcoding the context path into your URL. (ie
move your app to /test2 and a browser will still look for your images at
/test). The only way an app server could fix this is by parsing EVERY url in
your page - a nightmare for speed and accuracy.
How to fix?
If you use <%@ include page="/myinclude.jsp"> this will work fine relative
to the context root, so you don't have to change these includes when you
move your app.
For images, refernce them with <img src="<%= request.getContextPath()
%>/images/test.gif"> and it will work perfectly, even after moving the app.
The request.getContextPath here will be "/test".
Hope this helps,
Mike
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Kit Cragin
> Sent: Saturday, 8 April 2000 1:26
> To: Orion-Interest
> Subject: Fw: referencing resources within a web application
>
>
> Anyone have this problem?
>
> ----- Original Message -----
> From: Kit Cragin <[EMAIL PROTECTED]>
> To: Orion-Interest <[EMAIL PROTECTED]>
> Sent: Tuesday, April 04, 2000 12:20 PM
> Subject: referencing resources within a web application
>
>
> > I am not sure if the following is an Orion quirk, an oversight in the
> > servlet 2.2 spec, or something that has just not been thought
> about yet...
> > but I am having a problem with consistently referencing a
> resource from a
> > .jsp within a web application via Orion.
> >
> > Assume I have a web-app "test" that has the following directory layout:
> >
> > test/
> > test/WEB-INF/
> > test/WEB-INF/web.xml
> > test/images/
> > test/images/test.gif
> > test/stuff/
> > test/stuff/page.jsp
> >
> > and that page.jsp has this html code:
> >
> > <html><body>
> > <!-- #1 -->
> > <img src="/images/test.gif"/><br/>
> > <!-- #2 -->
> > <img src="images/test.gif"/><br/>
> > <!-- #3 -->
> > <img src="/test/images/test.gif"/><br/>
> > <!-- #4 -->
> > <img src="../images/test.gif"/><br/>
> > <!-- #5 -->
> > <img src="http://localhost/test/images/test.gif"/>
> > </body></html>
> >
> > For the case in which I have test/stuff/page.jsp as a welcome-file in
> > web.xml, <img> tags #2,3,5 properly display the image when
> browsing (i.e.
> > http://localhost/test/)
> >
> > For the case in which I directly address page.jsp in the browser (i.e.
> > http://localhost/test/stuff/page.jsp), <img> tags #3,4,5 work.
> >
> > This is inconsistent. Ideally, I would like #1 or #2 to work in
> both cases
> > (in fact section 9.4 of the servlet 2.2 spec seems to indicate #1 would
> > work). This would allow for maximum maintainability. For instance, #3
> means
> > I have to change all the references in all the JSP's should the name of
> the
> > application change; #4 means I have to change all the
> references if I move
> a
> > JSP within the application. #5, means I have to change all the
> references
> if
> > I move application to a different server.
> >
> > Now, most of the time users are redirected to the .jsp files in my
> > architecture anyway, so method #2 is fine. But.... I still
> regard this as
> > inadequate since that may not always be the case.
> >
> > Is there something I missed? Any ideas?
> >
> > thanks,
> >
> > Kit Cragin
> > VP of Product Development
> > Mongoose Technology, Inc.
> > www.mongoosetech.com
> >
> >
> >
> >
> >
>
>
>