-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

To whom it may concern,

On 6/9/2009 9:49 AM, ledbettd wrote:
> Inside both the header.jsp and footer.html files the same link is included:
>        /prds.jsp prds 
> 
> Both the default.jsp and pudire.jsp files include the footer.html and create
> the correct link inside the web page:
>       default.jsp = <%...@include file="/includes/footer.html"%> = works fine
>       pudire.sjp = <%...@include file="/includes/footer.html"%> = works fine

How about the code from footer.jsp (or header.jsp) that actually
generates the links?

> This include statement in default.jsp works fine and creates a valid path to
> the prds.jsp page:
>       <%...@include file="/includes/header.jsp"%>
>       The link it creates inside the web page is:
>       http://bcosite.com/prds.jsp
>       Correct link.
> 
> This include statement in pudire.jsp creates the wrong path to the prds.jsp
> page:
>       <%...@include file="/includes/header.jsp"%>
>       The link it creates for the web page is:
>       http://bcosite.com/pudire/prds.jsp
>       Wrong link...it added the /pudire directory into the link href??

You are probably not creating the links correctly. One proper way to
create a link in a JSP (there are others, depending on your environment)
is to do this:

<a href="<%= response.encodeURL(request.getContextPath()
         + "/full/path/to/resource.jsp"))%>">link text</a>

Certain url-generating JSP tag libraries already do proper encoding of
the URL (to encode jsessionid if necessary) as well as prefixing the
full path to the link resource with the context path, which is nice.

The three points to take away from this tip are:

1. Always use fully-specified URLs, otherwise including files from other
directories will cause headaches such as those you are experiencing.
2. Always prepend the webapp's context path to your URLs
3. Always run your URLs through response.encodeURL
  (or response.encodeRedirectURL if you're redirecting)

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkouwCIACgkQ9CaO5/Lv0PBpaACgnoRuxzbGX1SML0cm/xxDvqOv
NwcAn1cbJPZs/RBFT3+Yyr8lmJ6XRp5p
=yVhb
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to