Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes Mr. Carver -- My Previous Question With Error Messages Attached Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Mr. Carver -- My Previous Question With Error Messages Attached" Watch "Mr. Carver -- My Previous Question With Error Messages Attached" New topic
Author

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

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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

Joined: Jun 03, 2000
Posts: 5040
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).]


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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

Joined: Jan 08, 2001
Posts: 2164
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

Joined: Nov 19, 2000
Posts: 1309
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

Joined: Jan 07, 1999
Posts: 6920
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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mr. Carver -- My Previous Question With Error Messages Attached
 
Similar Threads
Problem with Packages / Utility Classes in Servlets
Servlets - Something Basic is Wierd, Need Someone to Pinpoint the Problem
Problem With JDK1.3 -- I Posted Before, But Could Not Get A Solution
The requested resource () is not available
Similar JDK1.3 Problem to Mr. Norman Leach -- Please Help