• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mr. Carver -- My Previous Question With Error Messages Attached

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JiaPei:
To the best of my knowledge, even JDK1.2.2 doesnot
import javax.servlet.*
I would check the classpath with which they compiled
under JDK1.2.2 and compare it to the classpath under
your JDK1.3
Hope I am on the right track Frank..........
regds.
- satya

[This message has been edited by Madhav Lakkapragada (edited January 12, 2001).]
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is the same path.
Months ago, before JDK1.3 was made available, I did Servlet projects using JDK1.2.2 without problem.
After JDK1.3 made available, I deleted JDK1.2.2 from my machine, and have since using JDK1.3. There has been no problem to compile other java programs (other than Servlets) using JDK1.3.
I started doing lots of tests only when I ran into problem to compile "Servlets" program using JDK1.3. I put JDK1.3 away, brought back JDK1.2.2, and things work.
I would say I run into a very wierd situation. I don't understand the problem. Wish someone could pinpoint the problem.
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi JiaPei,
don�t forget that the javax.servlet package never ever was part of the jsdk. Even not with jsdk 1.2.2. It is very simple to solve your problem. Search your computer for a file named servlet.jar. If u have a servlet engine on that computer it should be there. Then put the servlet.jar in the classpath (set Classpath=%Classpath%;<yourPath>\servlet.jar) on the command line.
Can be that I have read something about that you can put servlet.jar in the lib directory of the jsdk, but as a real greenhorn I'm not sure.
have a nice day...
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am afraid that it does no solve my problem. I am talking JDK 1.2.2 vs JDK 1.3.
My Servlet programs get compiled fine using JDK 1.2.2 and the same Servlet programs get compilation errors using JDK 1.3.
What a mistery.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
During your development process you may have added the servlet API as a jar file to your JDK1.2.2 jre/lib/ext directory, which would have made it automatically available to your programs. If you subsequently deleted all of JDK1.2.2 without copying over any extra jar files to JDK1.3 then those APIs will no longer be available. Do a "find" on your system and look for "servlet.jar". If it's not there then you won't be able to use the servlet API.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic