[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

Running servlets on Apache

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
0
karthik_212
Asked:
karthik_212
2 Solutions
 
radarshCommented:
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
0
 
TimYatesCommented:
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
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now