aspose file tools*
The moose likes Cattle Drive and the fly likes Servlets - Java Ranch Tutorial Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Servlets - Java Ranch Tutorial Help " Watch "Servlets - Java Ranch Tutorial Help " New topic
Author

Servlets - Java Ranch Tutorial Help

Tony Combe
Greenhorn

Joined: Mar 14, 2002
Posts: 17
Hi
I've been having problems getting the first servlet in the Java Ranch Tuutorial to work. I'm new to servlets and using the jdk (I usually use J Builder) so it's probably something stupid I've missed but I cant see it. I downloaded the JavaRanchCommon.zip file and renamed it .jar. Then I put it in the directory required in the orion bit and then I compiled the BeeServlet in the orion directory where the JavaRanchCommon.jar file is supposed to be. Then I get the following errors from the javac.
package com.Javaranch.common.* does not exist
cannot resolve symbol
symbol : class LogServlet
location : class BeeServlet
cannot resolve symbol
symbol : class CastMap
location : class BeeServlet
Can anyone help?
Greg Harris
Ranch Hand

Joined: Apr 12, 2001
Posts: 1012
did you put JavaRanchCommon.zip or .jar in your classpath?
i have it in /java/JavaRanchCommon.jar and my classpath looks like:
SET CLASSPATH=%CLASSPATH%d:\java\JavaRanchCommon.jar;


what?
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Have you done the OOP assignments yet? The servlet assignments build on some of the stuff introduced in the OOP assignments.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Tony Combe
Greenhorn

Joined: Mar 14, 2002
Posts: 17
As far as I know I have'nt got a CLASSPATH variable SET ie when I type set in the DOS prompt CLASSPATH does not appear as a separate heading but the PATH variable has the neccessary reference to the JDK bin. I read through suns installation intructions for the JDK and although some of it went over my head it seemed to be saying that setting the CLASSPATH permenently was not the preffered method rather set using the tools like javac and java. Is my interpretation correct or just a load of B*****KS. Please Advise.
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Hi Tony,
The hidden hint in Marilyn's question refers to a couple of tips you get back in an earlier assignment ( Assignment OOP-1 ) where you first use the common.javaranch.com package.
As far as whether you set your classpath in your system or use the options when you type java or javac, I think you can go either way. Don't know if one is better than the other.
Pauline
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Although setting the classpath can be done either way (permanently or on the fly), I think it is simpler for beginners to set a permanent classpath.
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
I'd have to agree, setting the classpath once is a heck of a lot easier.
For some reason, none of my instructors get this. Everytime they decide to fire up a Java app to show us that their code works (once they actually get it debugged with help from the class... and it's not intentional that they do that, btw), they have to set the classpath. Then they close out the window, come back later for another program, go through the same ol' steps, set the classpath again to the same friggin directory, etc etc.
You know, there's a reason why we work towards the "code once" golden rule, should apply that to other situations, too.
Greg Harris
Ranch Hand

Joined: Apr 12, 2001
Posts: 1012
Originally posted by jason adam:
Everytime they decide to fire up a Java app to show us that their code works (once they actually get it debugged with help from the class... and it's not intentional that they do that, btw)

so it's not just my teacher that does this!?
Tony Combe
Greenhorn

Joined: Mar 14, 2002
Posts: 17
Hello Again thanks all for your help so far. Have managed to get a couple of probs sorted through looking at earlier lessons as suggested, but it's coming up with another error now. Here it is.
cannot access javax.servlet.http.Http.Servlet
file javax\servlet\http\HttpServlet.class not found
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Looks like a typo Tony. Could it be that you have an import statement like this:
import javax.servlet.http.Http.Servlet ;
Maybe the period between Http and Servlet is causing a problem?

Pauline
[ March 28, 2002: Message edited by: Pauline McNamara ]
Greg Harris
Ranch Hand

Joined: Apr 12, 2001
Posts: 1012
i have seen that error before... actually, just a couple days ago when i transferred all my java files to d: from c:
i forgot to change one of my classpath items. you need to put j2ee.jar in your classpath.
my classpath looks like:
SET CLASSPATH=%CLASSPATH%d:\j2sdkee1.2.1\lib\j2ee.jar;
this is from the "Servlets" page on this site:
"Download J2EE (Java 2 Enterprise Edition Software Development Kit) from Sun, and install it. It is a supplement to the JDK you already have installed. You need to include the j2ee.jar in your classpath."
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1195
I just don't get this whole Classpath thing. I thought I understood.......
Does anyone else have a mental block with classpath?
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1746
    
    2
Yep, Carol. I've had many a wrestling match with classpaths.
There's a great thread on the beginner's forum right now called "O Classpath, why do you hate me?" or something like that.
Tony Combe
Greenhorn

Joined: Mar 14, 2002
Posts: 17
This is the last time I'm going to bug anyone about this particular thing (fingers crossed just in case :-).
Have finally got the BeeServlet to work but I'm confused. What I did was to type the j2ee.jar into the classpath on the dos propmt and it worked fine but when it was in the (Global) CLASSPATH it didn't work. If I use the dos Prompt classpath does that mean it cancels out the global Classpath for that compilation. Or does it use both when searching for user classes.
Greg Harris
Ranch Hand

Joined: Apr 12, 2001
Posts: 1012
when you say "global classpath", are you referring to the line you type in "autoexec.bat"? if so, you have to restart your computer before that will take effect.
when you "set" the classpath from the command line in DOS, it just stays while you have that DOS windown session running.
(please correct me if i am wrong here...)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlets - Java Ranch Tutorial Help