wood burning stoves 2.0
The moose likes Servlets and the fly likes ServletUtilities class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletUtilities class" Watch "ServletUtilities class" New topic

ServletUtilities class

Xinbo Cheng

Joined: Jan 05, 2001
Posts: 15

All the servlets mentioned here are examples from Marty Hall's "Core Servlets and JavaServer Pages".
I was able to get the HelloWWW2 servlet and SnoopServlet to run properly. But when I tried to compile HelloWWW3 or LotteryNumbers
servlets, I encountered an error in both cases:
undefined variable or class name: ServletUtilities
I was able to compile ServletUtilities.java and the
class file was in the proper folder.
I do not understand why I can't get the servlets which
call the ServletUtilities.headWithTitle("") method to work.
All these servlets do is call a static method in a public class.
Does anybody have any idea what is happening? Thanks a lot!
Xinbo Cheng

Joined: Jan 05, 2001
Posts: 15
I'd like to add that my problem appears to be a result of the fact that Both HelloWWW3.java and ServletUtilities.java belongs to the coreservlets package. If I comment out package coreservlets in both .java files and set the classpath properly, I can compile and run the HelloWWW3 servlet with no problem.
More details, I have a Myservletc.bat file (see below) sitting in C:\Windows\command. and my servlet .java files( all belong to coreservlets package) are in C:\MyServlets\coreservlets.
here is how I compile:
C:\MyServlets\coreservlets>Myservletc HelloWWW3.java
Here I have an error message:
undefined variable or class name: ServletUtilities
(Note HelloWWW3.java calls ServletUtilities.method(), the later is a static method.)
I may be asking a very simple question: How do I set the classpath so I can compile all related .java files belong to the same package?
Your help is greatly appreciated!
@echo off
rem This is the version for the Tomcat server
set CLASSPATH=C:\tomcat\lib\servlet.jar; C:\tomcat\lib\jasper.jar; C:\MyServlets;C:\MyServlets\ChengServlets;%CLASSPATH%
C:\jdk1.2\bin\javac -d C:\tomcat\webapps\ROOT\WEB-INF\classes %1%
rem last line is just to deposit .class file in ...\classes
rem folder.
I agree. Here's the link: http://aspose.com/file-tools
subject: ServletUtilities class
It's not a secret anymore!