Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to tun servlet in Tomcat 5 1

Status
Not open for further replies.

Vadim

Programmer
Feb 5, 2002
75
US
I loaded Tomcat on my new computer.
When I run this string:
"It give me the 404 error:
HTTP Status 404 - The requested resource (/servlet/salesreport3.Salesreport03) is not available.

The JSP pages are working fine. My servlet address is
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes\salesreport3\Salesreport03.class
What should I changed to make it runnable?

Thanks.
 
Make sure you /ROOT/WEB-INF/web.xml file looks like this :

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "file:///usr/tomcat/web-app_2_2.dtd">

<web-app>
	<servlet>
		<servlet-name>Salesreport</servlet-name>
		<servlet-class>salesreport3.Salesreport03</servlet-class>                   
		<load-on-startup>1</load-on-startup>
	</servlet>	
	<servlet-mapping>
		<servlet-name>Salesreport</servlet-name>
		<url-pattern>/servlet/Salesreport</url-pattern>
	</servlet-mapping>	

</web-app>
 
I have many applications - I'd like to make it generic as possible, and not change web.xml, if I create a new. May you help me to create something like that:
Code:
   <servlet>
        <servlet-name></servlet-name>
        <servlet-class>*.*</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name></servlet-name>
        <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
 
I'm afraid not like that you won't. However, if you uncomment the "invoker" servlet in TOMCAT_HOME/conf/web.xml, you will achieve a similar effect. I'm not sure if this would map a servlet such as "com.acme.TestServlet" to a "/servlet/TestServlet" mapping though - I guess you'll need to try it. If that does not work, then you will have to map them one by one - this is standard practice though ...
 
Sedj, You right, I already found that somewhere in documentation (about invoker) - it's work fine.
Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top