You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Colin Freas <Co...@faa.gov> on 2000/10/04 17:34:25 UTC
'servlet' in URL
Is there any way to set Tomcat to deliver servlets without the string
'servlet' appearing anywhere in the URL?
Colin
Re: 'servlet' in URL
Posted by James Cribb <ja...@zip.com.au>.
Colin Freas wrote:
>
> Is there any way to set Tomcat to deliver servlets without the string
> 'servlet' appearing anywhere in the URL?
Yes: add them to the context's WEB-INF/web.xml file. But the format of
this file is not explained in the docs that come with Tomcat. You need
to get the Java Servlet 2.2 Specification from Sun
(http://java.sun.com/products/servlet/download.html#specs) and read
chapter 13 "Deployment Descriptor". Here's how your web.xml file might
look:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>
eric
</servlet-name>
<servlet-class>
FunkyServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
eric
</servlet-name>
<url-pattern>
/grind
</url-pattern>
</servlet-mapping>
</web-app>
Then, if your Tomcat server.xml defines context "/colin" to be the
parent directory of the WEB-INF directory that contains this web.xml
file (!), you can run the FunkyServlet servlet using
"http://host/colin/grind".
Complicated, isn't it.
Re: 'servlet' in URL
Posted by Jon Skeet <jo...@peramon.com>.
> Is there any way to set Tomcat to deliver servlets without the string
> 'servlet' appearing anywhere in the URL?
Absolutely - just set up an appropriate context path. I'd have thought
you'd have to go slightly out of your way to *make* it use servlet. How
much of the documentation have you read, out of interest?
Jon