This program (see below) (and my many other
Servlets programs) were compiled using JDK 1.2.2 without problem. When I use JDK 1.3 to compile this program, I got six error messages. To my understanding, the JDK 1.3 somehow does not import javax.servlet.*; and import javax.servlet.http.*; (error messages are listed after the program).
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ThreeParams extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Reading Three Request Parameters";
out.println("<DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">" + "\n" +
"<HTML>\n" +
"<HEAD><TITLE>" + "Three Parameters" + "</TITLE></HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\n" +
"<UL>\n" +
" <LI><B>param1</B>: "
+ request.getParameter("param1") + "\n" +
" <LI><B>param2</B>: "
+ request.getParameter("param2") + "\n" +
" <LI><B>param3</B>: "
+ request.getParameter("param3") + "\n" +
"</UL>\n" +
"</BODY></HTML>");
}
}
error message:
The first two error messages point at
import javax.servlet.*;
import javax.servlet.http.*;
The other four error messages are:
ThreeParams.java:17: cannot resolve symbol
symbol: class HttpServlet
location: class ThreeParams
public class ThreeParams extends HttpServlet {
(an arrow point at the 'H' of HttpServlet)
ThreeParams.java:19: cannot resolve symbol
symbol: class HttpRequest
location: class ThreeParams
public void doGet( HttpServletRequest request,
(an arrow points at the 'H' of HttpServletRequest)
ThreeParams.java:20: cannot resolve symbol
symbol: class HttpServletResponse
location: class ThreeParams
HttpServletResponse response )
(an arrow points at the 'H' of HttpServletResponse)
ThreeParams.java:21: cannot resolve symbol
symbol: class ServletException
location: class ThreeParams
throws ServletException, IOException {
(an arrow points at the 'S' of ServletException)
It seems that the JDK1.3 in my machine cannot import javax. Do you know what went wrong? and how to fix the problem? Thank you.