You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by itsme reda <re...@yahoo.com> on 2003/09/21 14:51:18 UTC

a beginner pb

Hallo 
i am beginner to servlets and tomcat , i ve installed
Tomcat 4.1.27 under linux

i ve specified all variables CATALINA_HOME AND
JAVA_HOME, i ve no pb in executing servlets that are
coming with tomcat (in the example folder). 

but i ve a pb to run some servlets that i ve put in a
test folder under webapps . every thing is correct
because i got those servlet from a cd of a book. the
pb that i get when i call this servlet from the
browser- knowing that the url introduced is correct
-is 404
can anyone help me to resolve this pb

THanks you

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: a beginner pb

Posted by Peter Harrison <pe...@nothingbutnet.co.nz>.
On Mon, 22 Sep 2003 00:51, itsme reda wrote:

> but i ve a pb to run some servlets that i ve put in a
> test folder under webapps . every thing is correct
> because i got those servlet from a cd of a book. the
> pb that i get when i call this servlet from the
> browser- knowing that the url introduced is correct
> -is 404
> can anyone help me to resolve this pb

First of all putting some servlets in a folder under webapps won't nessasarily 
work. At the very least you need the following structure:

/WEB-INF directory
/WEB-INF/classes directory
/WEB-INF/web.xml file

The web.xml file can be very minimal, but is required in order for tomcat to 
recognise it as a web application. Also, how are you calling the servlet? If 
you want to call a servlet directly it usually looks somthing like:

http://localhost:8080/test/servlet/com.foo.MyTestServlet

However, if you want to have a more friendly URL you can create a mapping in 
the web.xml file like this:

	<servlet>
		<servlet-name>test</servlet-name>
		<servlet-class>com.foo.MyTestServlet</servlet-class>
	</servlet>

	<servlet-mapping>
		<servlet-name>test</servlet-name>
		<url-pattern>test</url-pattern>
	</servlet-mapping>

Regards,
Peter

Re: a beginner pb

Posted by Peter Harrison <pe...@nothingbutnet.co.nz>.
On Mon, 22 Sep 2003 00:51, itsme reda wrote:

> but i ve a pb to run some servlets that i ve put in a
> test folder under webapps . every thing is correct
> because i got those servlet from a cd of a book. the
> pb that i get when i call this servlet from the
> browser- knowing that the url introduced is correct
> -is 404
> can anyone help me to resolve this pb

First of all putting some servlets in a folder under webapps won't nessasarily 
work. At the very least you need the following structure:

/WEB-INF directory
/WEB-INF/classes directory
/WEB-INF/web.xml file

The web.xml file can be very minimal, but is required in order for tomcat to 
recognise it as a web application. Also, how are you calling the servlet? If 
you want to call a servlet directly it usually looks somthing like:

http://localhost:8080/test/servlet/com.foo.MyTestServlet

However, if you want to have a more friendly URL you can create a mapping in 
the web.xml file like this:

	<servlet>
		<servlet-name>test</servlet-name>
		<servlet-class>com.foo.MyTestServlet</servlet-class>
	</servlet>

	<servlet-mapping>
		<servlet-name>test</servlet-name>
		<url-pattern>test</url-pattern>
	</servlet-mapping>

Regards,
Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org