It's the browser that composes the full URL from the request URL and the
relative path. The base tag can override the use of the request URL.
If the relative path starts off with '/', the browser assumes the
resource to come from the same server/port over the same protocol and
makes a request for it from the same place it got the page from. If
there is no protocol, no server name, and the relative path does not
start with '/', the browser removes what it can determine is the file
name and request params from the page's URL and tacks on the relative url.
Example:
Page is requested from http://www.some.server.com/some/path/to/the/page.html
Resource requested is '/doc/pdf/paper.pdf':
Browser assumes full path to be http://www.some.server.com/doc/pdf/paper.pdf
Resources requested is 'doc/pdf/paper.pdf' (note missing leading '/'):
Browser assumes full path to be
http://www.some.server.com/some/path/to/the/doc/pdf/paper.pdf
The easy way to take care of 99.99 percent of issues in jsps is to just do:
<a href="<%= pageContext.getRequest().getContextPath()
%>/path/to/resource.jpg">Link text here</a>
or even easier with EL expression language (servlet spec 2.4+, might
have started earlier):
<a href="${pageContext.request.contextPath}/path/to/resource.pdf">Link
text here</a>
As long as the resource is in the same webapp on the same server/port
and transported with the same protocol, it'll just plain work regardless
of the webapp's name, server, port, etc., ...
--David
Burak Yýlmaz wrote:
My links was not starting with "/" i misswrote it sorry.
now when i wrote my links starting with "/" and links are like;
/images/xxx.jpg
and the images are displayed now. Anyway i now i have to put "/" on the start
of my every link...
I still didnt understand this path system is supplied by tomcat? ,browser
compiler like ie,firefox? or java?...
In fact its still not the real solution that i want. I have tried all ways of
wrapping the request object but understood that its not related with request
variables. So thats why i came here and started to think that if i can override
any tomcat parameters and solve this pathing problem.
----- Original Message ----
From: Hassan Schroeder <[EMAIL PROTECTED]>
To: Tomcat Users List <users@tomcat.apache.org>
Sent: Monday, July 30, 2007 8:17:09 PM
Subject: Re: How to change(override) application path
On 7/30/07, Burak Yýlmaz <[EMAIL PROTECTED]> wrote:
my links to images,css,js are like below in jsp files;
/images/xxx.jpg
/js/xxx.js
/css/xxx.css
solution is fully re rewriting the url's i know like;
No, not at all. If your links are really absolute paths, it should just
work. The only way something like "mycontext/album/images/xxx.gif"
would happen is if the link is relative -- not starting with "/".
Perhaps you should post an actual JSP that demonstrates the issue...
____________________________________________________________________________________
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545433
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]