This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletUtilities class" Watch "ServletUtilities class" New topic
Author

ServletUtilities class

Xinbo Cheng
Greenhorn

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
Xinbo Cheng
Greenhorn

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!
----------------------------------------------------
Myservletc.bat
@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.
 
Don't get me started about those stupid light bulbs.
 
subject: ServletUtilities class
 
Similar Threads
Package
compiling with packages
Testing Servlet3.java - Errors
package issue
how to compile with utilityclass