Hi

I've had all sorts of problems understanding how relative links are
resolved so I found this solution somewhere and it works well for me

All my pages import a header file (header.jsp) in header.jsp I have this

<%
String basePath = request.getScheme()+"://"+request.getServerName()+"/";
%>

<html>
  <head>
    <base href="<%=basePath%>">
     ....

Now I no longer have any problems with links not working, ever.

I have my app installed as the default app. If you are using a non
ROOT context you can append request.getContextPath() like this


<%
String basePath =
request.getScheme()+"://"+request.getServerName()+"/"+request.getContextPath()+"/";
%>

It works for me

Rgds
Duncan

On 7/30/07, Burak Yýlmaz <[EMAIL PROTECTED]> wrote:
> My question is related with java but i think the solution is at the tomcat 
> global variables so i need this groups help.
>
> I want my web links to be like www.mydomain.com/album/13
>
> with the help of the front controller at java i will translate the url to 
> www.mydomain.com/album.jsp?id=3 and dispatch it to the jsp file...
>
> at web.xml i configured the url pattern like below
>
>   <servlet>
>         <servlet-name>Controller</servlet-name>
>         <servlet-class>com.mydomain.Controller</servlet-class>
>   </servlet>
>
>   <servlet-mapping>
>         <servlet-name>Controller</servlet-name>
>         <url-pattern>/album/*</url-pattern>
>   </servlet-mapping>
>
>
> Everything is ok if i type the url like mydomain.com/album
>
> But
> if i type mydomain.com/album/ or mydomain.com/album/13 my pages are
> displayed but the images,css files,js files cannot be imported....This
> is because application tries to get the images from like
> mycontext/album/images/xxx.gif but in fact the images are under
> mycontext/images/xxx.gif
>
>
> Because of this urlrewriting i have this path problem...So there must be some 
> option i will re set exmp: TOMCAT.Application.Path="http://www.mydomain.com/"; 
> everytime after recreation of real url and my images and other files will be 
> displayed correctly.
>
> thank you
>
> Burak
>
>
>
>
>
> ____________________________________________________________________________________
> Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, 
> news, photos & more.
> http://mobile.yahoo.com/go?refer=1GNXIC
>
> ---------------------------------------------------------------------
> 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]

Reply via email to