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

NoClassDefFoundError: javax/servlet/http/HttpServlet

Status
Not open for further replies.

Ghodmode

Programmer
Feb 17, 2004
177
NZ
I'm using Apache Tomcat 6.0.14 with Java 1.6.0_02.

I've been having some trouble loading servlets, so I tried a basic HelloWorld type program just to make sure everything was okay and it can't find the servlet-api.jar.

Isn't it supposed to automatically load all of the jar files in $CATALINA_HOME/lib?

Here's my code:
Code:
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;

public class HelloServlet extends HttpServlet
{
	public void doGet( HttpServletRequest req, HttpServletResponse resp )
		throws ServletException, IOException
	{
		PrintWriter writer = resp.getWriter();
		writer.println( "<h1>Hello World</h1>" );
	}
}

Here's my web.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
   "[URL unfurl="true"]http://java.sun.com/dtd/web-app_2_3.dtd">[/URL]
<web-app>
	<servlet>
		<servlet-name>HelloServlet</servlet-name>
		<servlet-class>HelloServlet</servlet-class>
	</servlet>

	<servlet-mapping>
		<servlet-name>HelloServlet</servlet-name>
		<url-pattern>/helloservlet/*</url-pattern>
	</servlet-mapping>
</web-app>

Thank you,

--
-- Ghodmode

Give a man a fish and he'll come back to buy more... Teach a man to fish and you're out of business.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top