You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Duncan Strang <ds...@ukeu.com> on 2003/08/21 12:14:20 UTC
Setting the root application
Hi
I hope you don't consider this too trivial a question but I have tried
everything I can think of to get this working. I have read as much of
the docs as I can, looked at the faq's and searched the archives. I know
the information is there but I can't find it.
I want to make my application the root application.
That is, I don't want to have to type in the context path after the port
I just want to type http://localhost:8080
Actually I have this working.
The first resource accessed is a Servlet
here's my servlet mapping
<servlet-mapping>
<servlet-name>LocaleChecker</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
When I access http://localhost:8080 <http://localhost:8080/> the
servlet executes and forwards the request to a jsp dependant on weather
a cookie is available
here is the server.xml that sets the root application
<Context path="" docBase="mydir" debug="0"/>
here is the jsp that is being executed
...
<%System.out.println("JSP resource paths = " +
application.getResourcePaths("")); %>
<br><br>
<table>
<tr>
<td><img src="/images/england.gif"></td>
</tr>
</table>
...
The output from getResourcePaths is
JSP resource paths = [/header.jsp, /images/, /.nbattrs, /getCountry.jsp,
/WEB-INF/]
Yes, the images are available in the images directory.
However, no matter what I do I cannot get the images to display. I have
tried every conceivable path expression without luck.
Any halp much appreciated.
Cheers
Duncan L.Srang
Re: Setting the root application
Posted by Tim Funk <fu...@joedog.org>.
Via the spec: (SRV.11.2 Specification of Mappings)
"A string containing only the ’/’ character indicates the "default" servlet
of the application. In this case the servlet path is the request URI minus
the context path and the path info is null."
As for "images/foo.gif", this is translated to /images/foo.gif (or whatever
the relative context is) by the web client.
EVERY valid HTTP reques starts with a / and is followed by something. If not,
you may see the following:
===============
funkman@wookie: telnet ralph 80
Trying 198.168.0.1...
Connected to 198.168.0.1.
Escape character is '^]'.
GET wookie HTTP/1.1
Host: what.ralph.bent.com
Connection: close
HTTP/1.1 400 Bad Request
Date: Thu, 21 Aug 2003 18:09:11 GMT
Server: Apache/1.3.26 (Unix) mod_gzip/1.3.19.1a mod_jk/1.2.1
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
...
===============
-Tim
Mike Curwen wrote:
> Actually, isn't "/" the default servlet ? "/*" would be "every
> request", but just a single slash is 'when you don't recognize a
> request, try this servlet'.
>
> Do you think <img src="images/foo.gif"> would work? (no leading / on
> the image path)
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Setting the root application
Posted by Tim Funk <fu...@joedog.org>.
Via the spec: (SRV.11.2 Specification of Mappings)
"A string containing only the ’/’ character indicates the "default" servlet
of the application. In this case the servlet path is the request URI minus
the context path and the path info is null."
As for "images/foo.gif", this is translated to /images/foo.gif (or whatever
the relative context is) by the web client.
EVERY valid HTTP reques starts with a / and is followed by something. If not,
you may see the following:
===============
funkman@wookie: telnet ralph 80
Trying 198.168.0.1...
Connected to 198.168.0.1.
Escape character is '^]'.
GET wookie HTTP/1.1
Host: what.ralph.bent.com
Connection: close
HTTP/1.1 400 Bad Request
Date: Thu, 21 Aug 2003 18:09:11 GMT
Server: Apache/1.3.26 (Unix) mod_gzip/1.3.19.1a mod_jk/1.2.1
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
...
===============
-Tim
Mike Curwen wrote:
> Actually, isn't "/" the default servlet ? "/*" would be "every
> request", but just a single slash is 'when you don't recognize a
> request, try this servlet'.
>
> Do you think <img src="images/foo.gif"> would work? (no leading / on
> the image path)
RE: Setting the root application
Posted by Mike Curwen <gb...@gb-im.com>.
Actually, isn't "/" the default servlet ? "/*" would be "every
request", but just a single slash is 'when you don't recognize a
request, try this servlet'.
Do you think <img src="images/foo.gif"> would work? (no leading / on
the image path)
> -----Original Message-----
> From: Tim Funk [mailto:funkman@joedog.org]
> Sent: Thursday, August 21, 2003 6:10 AM
> To: Tomcat Users List
> Subject: Re: Setting the root application
>
>
> That is because / matches EVERY request so you have replaced
> the default
> servlet. Your servelt is now responsible for serving images.
>
> An easy workaround is to:
> - use welcome file listing in web.xml
> - create a welcome file (ex: index.jsp) that redirects to
> your servlet mapped
> to a better mapping
>
> -Tim
>
> Duncan Strang wrote:
> > Hi
> >
> > I hope you don't consider this too trivial a question but I
> have tried
> > everything I can think of to get this working. I have read
> as much of
> > the docs as I can, looked at the faq's and searched the archives. I
> > know the information is there but I can't find it.
> >
> > I want to make my application the root application.
> > That is, I don't want to have to type in the context path after the
> > port I just want to type http://localhost:8080
> >
> > Actually I have this working.
> > The first resource accessed is a Servlet
> > here's my servlet mapping
> >
> > <servlet-mapping>
> > <servlet-name>LocaleChecker</servlet-name>
> > <url-pattern>/</url-pattern>
> > </servlet-mapping>
> >
> > When I access http://localhost:8080 <http://localhost:8080/> the
> > servlet executes and forwards the request to a jsp dependant on
> > weather a cookie is available here is the server.xml that sets the
> > root application
> >
> > <Context path="" docBase="mydir" debug="0"/>
> >
> > here is the jsp that is being executed
> >
> > ...
> >
> > <%System.out.println("JSP resource paths = " +
> > application.getResourcePaths("")); %>
> >
> > <br><br>
> > <table>
> > <tr>
> > <td><img src="/images/england.gif"></td>
> > </tr>
> > </table>
> >
> > ...
> >
> > The output from getResourcePaths is
> >
> > JSP resource paths = [/header.jsp, /images/, /.nbattrs,
> > /getCountry.jsp, /WEB-INF/] Yes, the images are available in the
> > images directory.
> >
> > However, no matter what I do I cannot get the images to display. I
> > have tried every conceivable path expression without luck.
> >
> > Any halp much appreciated.
> >
> > Cheers
> > Duncan L.Srang
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
RE: Setting the root application
Posted by Mike Curwen <gb...@gb-im.com>.
Actually, isn't "/" the default servlet ? "/*" would be "every
request", but just a single slash is 'when you don't recognize a
request, try this servlet'.
Do you think <img src="images/foo.gif"> would work? (no leading / on
the image path)
> -----Original Message-----
> From: Tim Funk [mailto:funkman@joedog.org]
> Sent: Thursday, August 21, 2003 6:10 AM
> To: Tomcat Users List
> Subject: Re: Setting the root application
>
>
> That is because / matches EVERY request so you have replaced
> the default
> servlet. Your servelt is now responsible for serving images.
>
> An easy workaround is to:
> - use welcome file listing in web.xml
> - create a welcome file (ex: index.jsp) that redirects to
> your servlet mapped
> to a better mapping
>
> -Tim
>
> Duncan Strang wrote:
> > Hi
> >
> > I hope you don't consider this too trivial a question but I
> have tried
> > everything I can think of to get this working. I have read
> as much of
> > the docs as I can, looked at the faq's and searched the archives. I
> > know the information is there but I can't find it.
> >
> > I want to make my application the root application.
> > That is, I don't want to have to type in the context path after the
> > port I just want to type http://localhost:8080
> >
> > Actually I have this working.
> > The first resource accessed is a Servlet
> > here's my servlet mapping
> >
> > <servlet-mapping>
> > <servlet-name>LocaleChecker</servlet-name>
> > <url-pattern>/</url-pattern>
> > </servlet-mapping>
> >
> > When I access http://localhost:8080 <http://localhost:8080/> the
> > servlet executes and forwards the request to a jsp dependant on
> > weather a cookie is available here is the server.xml that sets the
> > root application
> >
> > <Context path="" docBase="mydir" debug="0"/>
> >
> > here is the jsp that is being executed
> >
> > ...
> >
> > <%System.out.println("JSP resource paths = " +
> > application.getResourcePaths("")); %>
> >
> > <br><br>
> > <table>
> > <tr>
> > <td><img src="/images/england.gif"></td>
> > </tr>
> > </table>
> >
> > ...
> >
> > The output from getResourcePaths is
> >
> > JSP resource paths = [/header.jsp, /images/, /.nbattrs,
> > /getCountry.jsp, /WEB-INF/] Yes, the images are available in the
> > images directory.
> >
> > However, no matter what I do I cannot get the images to display. I
> > have tried every conceivable path expression without luck.
> >
> > Any halp much appreciated.
> >
> > Cheers
> > Duncan L.Srang
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Setting the root application
Posted by Tim Funk <fu...@joedog.org>.
That is because / matches EVERY request so you have replaced the default
servlet. Your servelt is now responsible for serving images.
An easy workaround is to:
- use welcome file listing in web.xml
- create a welcome file (ex: index.jsp) that redirects to your servlet mapped
to a better mapping
-Tim
Duncan Strang wrote:
> Hi
>
> I hope you don't consider this too trivial a question but I have tried
> everything I can think of to get this working. I have read as much of
> the docs as I can, looked at the faq's and searched the archives. I know
> the information is there but I can't find it.
>
> I want to make my application the root application.
> That is, I don't want to have to type in the context path after the port
> I just want to type http://localhost:8080
>
> Actually I have this working.
> The first resource accessed is a Servlet
> here's my servlet mapping
>
> <servlet-mapping>
> <servlet-name>LocaleChecker</servlet-name>
> <url-pattern>/</url-pattern>
> </servlet-mapping>
>
> When I access http://localhost:8080 <http://localhost:8080/> the
> servlet executes and forwards the request to a jsp dependant on weather
> a cookie is available
> here is the server.xml that sets the root application
>
> <Context path="" docBase="mydir" debug="0"/>
>
> here is the jsp that is being executed
>
> ...
>
> <%System.out.println("JSP resource paths = " +
> application.getResourcePaths("")); %>
>
> <br><br>
> <table>
> <tr>
> <td><img src="/images/england.gif"></td>
> </tr>
> </table>
>
> ...
>
> The output from getResourcePaths is
>
> JSP resource paths = [/header.jsp, /images/, /.nbattrs, /getCountry.jsp,
> /WEB-INF/]
> Yes, the images are available in the images directory.
>
> However, no matter what I do I cannot get the images to display. I have
> tried every conceivable path expression without luck.
>
> Any halp much appreciated.
>
> Cheers
> Duncan L.Srang
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Setting the root application
Posted by Tim Funk <fu...@joedog.org>.
That is because / matches EVERY request so you have replaced the default
servlet. Your servelt is now responsible for serving images.
An easy workaround is to:
- use welcome file listing in web.xml
- create a welcome file (ex: index.jsp) that redirects to your servlet mapped
to a better mapping
-Tim
Duncan Strang wrote:
> Hi
>
> I hope you don't consider this too trivial a question but I have tried
> everything I can think of to get this working. I have read as much of
> the docs as I can, looked at the faq's and searched the archives. I know
> the information is there but I can't find it.
>
> I want to make my application the root application.
> That is, I don't want to have to type in the context path after the port
> I just want to type http://localhost:8080
>
> Actually I have this working.
> The first resource accessed is a Servlet
> here's my servlet mapping
>
> <servlet-mapping>
> <servlet-name>LocaleChecker</servlet-name>
> <url-pattern>/</url-pattern>
> </servlet-mapping>
>
> When I access http://localhost:8080 <http://localhost:8080/> the
> servlet executes and forwards the request to a jsp dependant on weather
> a cookie is available
> here is the server.xml that sets the root application
>
> <Context path="" docBase="mydir" debug="0"/>
>
> here is the jsp that is being executed
>
> ...
>
> <%System.out.println("JSP resource paths = " +
> application.getResourcePaths("")); %>
>
> <br><br>
> <table>
> <tr>
> <td><img src="/images/england.gif"></td>
> </tr>
> </table>
>
> ...
>
> The output from getResourcePaths is
>
> JSP resource paths = [/header.jsp, /images/, /.nbattrs, /getCountry.jsp,
> /WEB-INF/]
> Yes, the images are available in the images directory.
>
> However, no matter what I do I cannot get the images to display. I have
> tried every conceivable path expression without luck.
>
> Any halp much appreciated.
>
> Cheers
> Duncan L.Srang
>
>
>