We help IT Professionals succeed at work.

Running servlets on Apache

karthik_212
karthik_212 asked
on
Medium Priority
282 Views
Last Modified: 2010-03-04
Hi,

I am not able to run servlets on Apache Tomcat server. I have installed Tomcat 5.0.28. My jdk version is 1.4.2_07. I am using eclipse as java editor. Each time i try to run the servlet, i am getting an error stating "requested resource not available".


Thanks,

Karthik
Comment
Watch Question

Commented:
Hi karthik_212,

1. Your servlets should have a package declaration
2. You should place the servlet class in WEB-INF\classes folder, following the package structure.
   If com.foo.TestServlet, you should place TestServlet.class in WEB-INF\classes\com\foo directory.

________
radarsh

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT
Top Expert 2004
Commented:
You also need to declare your servlets and the mapping to them in the WEB-INF/web.xml file

ie:

    <servlet>
        <servlet-name>MyServlet</servlet-name>
        <servlet-class>com.foo.TestServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>MyServlet</servlet-name>
        <url-pattern>/MyServletMapping</url-pattern>
    </servlet-mapping>

Then go to http://localhost:8080/yourwebapp/MyServletMapping

And your servlet should run :-)

Tim
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.