You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Burak Yýlmaz <ne...@yahoo.com> on 2007/07/30 17:50:00 UTC
How to change(override) application path
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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: How to change(override) application path
Posted by David Smith <dn...@cornell.edu>.
How is the jsp composing the relative urls to images and stylesheets?
I typically have jsps reference urls by doing
${pageContext.request.contextPath}/path/to/resource.jpg for example.
That fills in the context path and forms a site absolute path to the
resource. The jsp can move around and more importantly the URL to it
can change without breaking links to resources.
--David
Burak Yýlmaz 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: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: How to change(override) application path
Posted by Lyallex <ly...@gmail.com>.
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 <ne...@yahoo.com> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org