I am reading and exercising Head First
Servlets and
JSP, and I follow the instruction of the book to create the servlet in chapter 3. But I failed to compile the BeerSelect.java. Could somebody point out what's wrong with my code or compiling? Thanks.
Tomcat5.5.17 was installed at:
C:\Apache\Tomcat
I am compiling the code right under the Beer directory
The command I inputed was:
javac -cp C:\Apache\Tomcat\common\lib\servlet-api.jar:classes:. -d src\com\example\web\BeerSelect.java
the compile output
src\com\example\web\BeerSelect.java:4: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
My code for BeerSelect.java is as following
package com.example.web;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class BeerSelect extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice <br>");
out.println("<br>Got Beer Color " +
request.getParameter("color"));
}
}