compiling a servlet

B

bob

I just installed Tomcat, and I'm trying to recompile the examples that
come with it. I get the following error:

HelloWorldExample.java:23: package javax.servlet does not exist
import javax.servlet.*;
^
HelloWorldExample.java:24: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
HelloWorldExample.java:32: cannot find symbol
symbol: class HttpServlet
public class HelloWorldExample extends HttpServlet {
^
HelloWorldExample.java:35: cannot find symbol
symbol : class HttpServletRequest
location: class HelloWorldExample
public void doGet(HttpServletRequest request,
^
HelloWorldExample.java:36: cannot find symbol
symbol : class HttpServletResponse
location: class HelloWorldExample
HttpServletResponse response)
^
HelloWorldExample.java:37: cannot find symbol
symbol : class ServletException
location: class HelloWorldExample
throws IOException, ServletException
^
6 errors

C:\Program Files\Apache Software Foundation\Tomcat
5.0\webapps\servlets-examples
\WEB-INF\classes>


Does anyone know where these servlet packages are hiding? I thought
they came standard with J2SE.
 
W

Wendy S

Does anyone know where these servlet packages are hiding? I thought
they came standard with J2SE.

Servlets are J2EE (enterprise edition). Find 'servlet.jar' under Tomcat and
put on your classpath for compilation. It's usually in
$TOMCAT_HOME\common\lib\
 
B

bob

I searched my whole computer for servlet.jar, and nothing turned up
except jlnp-serverlet.jar. What's up with that?
 
W

Wendy S

I searched my whole computer for servlet.jar, and nothing turned up
except jlnp-serverlet.jar. What's up with that?

What version of Tomcat are you using? Tomcat 4.1 definitely includes
servlet.jar. Perhaps it's a different filename in newer versions.

You can either download J2EE from Sun and compile against that, or else
figure out which .jar file in Tomcat has the classes you need. I'm sure
it's in there somewhere.
 
J

Juha Laiho

Wendy S said:
What version of Tomcat are you using? Tomcat 4.1 definitely includes
servlet.jar. Perhaps it's a different filename in newer versions.

You can either download J2EE from Sun and compile against that, or else
figure out which .jar file in Tomcat has the classes you need. I'm sure
it's in there somewhere.

Look for servlet-api.jar (or was it servletapi.jar); that's how it's named
in the 5.x versions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top