I am just trying to get up and running with JSP, and have installed
Tomcat 5.0. I am using Sams "Teach Yourself JavaServer Pages". The code
in the book, and the instructions are all based on Tomcat 4.0.3.
(I am running Windows XP Professional).
When I try and compile the following:
-------------------------------------------
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ch01_06 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("<HEAD>");
out.println("<TITLE>");
out.println("A Web Page");
out.println("</TITLE>");
out.println("</HEAD>");
out.println("Hello there!");
out.println("</BODY>");
out.println("</HTML>");
}
}
-------------------------------------------
I get the following errors:
------------------------------
C:\Program Files\Apache Software Foundation\Tomcat
5.0\webapps\ch01>javac ch01_06.java
ch01_06.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
ch01_06.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
ch01_06.java:5: cannot resolve symbol
symbol : class HttpServlet
location: class ch01_06
public class ch01_06 extends HttpServlet
^
ch01_06.java:7: cannot resolve symbol
symbol : class HttpServletRequest
location: class ch01_06
public void doGet(HttpServletRequest request,
^
ch01_06.java:8: cannot resolve symbol
symbol : class HttpServletResponse
location: class ch01_06
HttpServletResponse response)
^
ch01_06.java:9: cannot resolve symbol
symbol : class ServletException
location: class ch01_06
throws IOException, ServletException
^
6 errors
-----------------------------------
I am guessing it is because my book tells me to set CLASSPATH to the
path for 'servlet.jar', but when I look in the 'lib' directory I only
see a 'servlet-api.jar' file. So I set the CLASSPATH to servlet-api.jar.
(When this didn't work I did try changing the path to 'servlet.jar' just
to check but same result).
But the code is written with "import javax.servlet.* " - is this the
problem?
Because I am totally new to Java I can't figure out what to change. I
also can't find a 'what's changed from Tomcat 4.0 to 5.0' file to help
me understand.
Anyone offer any advice?
Thanks
Steve Carson
Brisbane
Australia