Due to class visibility issues you are typically asking
for trouble if you put servlet.jar in the jre/lib/ext
directory.

It is normal to have to specify servlet.jar in the
classpath for the compiler as you show for your successful
compilation.

Note that due to CLASSPATH problems encountered with
Tomcat 3.2.x, both Tomcat 3.3 and Tomcat 4.x build their
classloader hierarchy internally and don't rely on the
CLASSPATH for more than a "startup" jar and maybe tools.jar.
This implies that for Tomcat 3.3 and Tomcat 4.x,
the CLASSPATH setting used to startup Tomcat isn't
sufficient for compiling servlets, etc.

In Tomcat 3.3, executing from TOMCAT_HOME "bin/tomcat.sh env"
or "bin\tomcat.bat env" will set the CLASSPATH to
something fairly equivalent to the jars Tomcat 3.3
uses while running.  It should be sufficient to compile
servlets and othe web server classes.  I'm not
sure what Tomcat 4.x does with an "env" argument.

For your simple case, servlet.jar is all that is
needed.  For a more complicated case, you may need
to include more.

Cheers,
Larry

> -----Original Message-----
> From: David J. Hamilton [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 10, 2002 6:18 PM
> To: Tomcat Users List
> Subject: Re: Servlet Compilation Error
> 
> 
> you might want to try putting the servletXYZ.jar file in your
> jdk/jre/lib/ext directory
> --David
> 
> 
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: "Tomcat Users List" <[EMAIL PROTECTED]>
> Sent: Thursday, January 10, 2002 03:02 PM
> Subject: Servlet Compilation Error
> 
> 
> 
> 
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> 
> public class HelloWorld extends HttpServlet
> {
>      public void doGet (HttpServletRequest request, 
> HttpServletResponse
> response)
>      throws IOException, ServletException
>      {
>           response.setContentType ("text/html");
>           PrintWriter out = response.getWriter ();
>           out.println ("<html>");
>           out.println ("<body>");
>           out.println ("<head>");
>           out.println ("<title>Hello World!</title>");
>           out.println ("</head>");
>           out.println ("<h1>Hello World!</h1>");
>           out.println ("</body>");
>           out.println ("</html>");
>      }
> }
> 
> 
> On trying to compile this servlet program, I get the error 
> message, "package
> javax.servlet does not exist".
> 
> On compiling the same program using this command "$javac -classpath
> /usr/local/tomcat-4.0.1/common/lib/servlet.jar 
> HelloWorld.java" there are no
> errors.
> 
> Does the compilation of the servlet depend on setting up the 
> proper context
> in
> the server.xml file???
> 
> Thanks in advance,
> 
> Samarth
> 
> 
> 
> 
> 
> _________________________________________________________
> 
> Do You Yahoo!?
> 
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> 
> 
> 
> --
> To unsubscribe:   <mailto:[EMAIL PROTECTED]>
> For additional commands: <mailto:[EMAIL PROTECTED]>
> Troubles with the list: <mailto:[EMAIL PROTECTED]>
> 

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to