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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

working with servlets 1

Status
Not open for further replies.

aarushi2001

Technical User
Nov 16, 2005
109
0
0
US
Hi,

I need help to work with servlets.

I have written SimpleServlet.java file and have stored it under:
C:\Program Files\apache-tomcat-5.5.12\webapps\ROOT\WEB-INF\classes
I have compiled the file.
I have also set the classpath.

When I try and call the servlet it is giving me following error:

HTTP Status 404 - /SimpleServlet
type Status report

message /SimpleServlet

description The requested resource (/SimpleServlet) is not available.

Do I need to configure web.xml?

Can anyone help?
Thanks
 
You need to put your servlet in a package.
Eg if you had :

Code:
package test;

then you need to compile and put the class in :

C:\Program Files\apache-tomcat-5.5.12\webapps\ROOT\WEB-INF\classes\test

Then you need to map your servlet in web.xml :

Code:
   <servlet>
      <servlet-name>SimpleServlet</servlet-name>
      <servlet-class>test.SimpleServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
      <servlet-name>SimpleServlet</servlet-name>
      <url-pattern>/SimpleServlet</url-pattern>
   </servlet-mapping>

If you do not know how to define and build classes in packages, then use google to find out how.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top