tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kitching Simon <Simon.Kitch...@orange.ch>
Subject RE: confugure the URL pattern
Date Tue, 19 Sep 2000 19:11:42 GMT
Hi

> -----Original Message-----
> From:	Hongbin Xie [SMTP:hongbin@contact.com]
> Sent:	Tuesday, September 19, 2000 8:55 PM
> To:	tomcat-user@jakarta.apache.org
> Subject:	confugure the URL pattern
> 
> Hello everyone,
> 
> With the requirement from the client, we need to configure our servlet
> url as the following:
> http://localhost/name/name, in which, name is the alias for sevlet name,
> right now, I just configure it to
> http://localhost/name/servlet/name, I don't know how to get rid of the
> /servlet in the middle, please give advice. Thanks for help.
> 
> Hongbin
	[Kitching Simon]  

	There is a little "convenience" feature that makes all your
	servlets automatically available via the "/webapp/servlet/{anyname}"
	url (that's what you're using at the moment to get your servlet
run).

	What you need to do is set up definitions and mappings explicitly
	for each servlet in the webapp/WEB-INF/web.xml file for your
	webapp.

	<servlet>
	    <servlet-name>servlet_1</servlet-name>
	    <servlet-class>com.xyz.Servlet1</servlet-class>
	</servlet>

	<servlet-mapping>
	    <servlet-name>
	        servlet_1
	    </servlet-name>
	    <url-pattern>
	        /runServletNumberOne
	    </url-pattern>
	</servlet-mapping>

	As shown above, you can map any URL you
	like to your servlet, even more than one URL
	can map to the same servlet if you want. The
	"servlet-name" tag is really only there to link
	the mapping with the class definition, it can 
	be any string you want. 

	And the servlet class can be anywhere in
	the CLASSPATH, though it is usually best
	to put it under WEB-INF/classes.

	File $TOMCAT_HOME/conf/web.dtd defines
	what tags can be included in your webapp's 
	WEB-INF/web.xml file.

	Hope this helps,

	Simon

Mime
View raw message