Need help w. the servlet.jar file.

S

Steve R. Burrus

Yes, I find myself in pretty immediate need for some help/assistance
with the servlet.jar file in a servlet! Now, I am mainly working with
the Tomcat application server, version 5.0.19. I know that this kind of
a file for this version of tomcat is called the "servlet-api.jar" file,
which I have in the proper place, in the "C:\tomcat 5.0\common\lib"
folder. But when I go to trying to compile a particular utilities class
that the servlet depends on, the "ServletUtilities.java" file, all that
I get is an error message saying that it is the wrong "symbol" or it's
missing or something like that! Can someone please help?
 
S

Sudsy

Steve said:
Yes, I find myself in pretty immediate need for some help/assistance
with the servlet.jar file in a servlet! Now, I am mainly working with
the Tomcat application server, version 5.0.19. I know that this kind of
a file for this version of tomcat is called the "servlet-api.jar" file,
which I have in the proper place, in the "C:\tomcat 5.0\common\lib"
folder. But when I go to trying to compile a particular utilities class
that the servlet depends on, the "ServletUtilities.java" file, all that
I get is an error message saying that it is the wrong "symbol" or it's
missing or something like that! Can someone please help?

1st step in problem determination: review the EXACT messages being
generated. Using a phrase such as "something like that" will not
generally prompt people to reply.
So we need to see the following:
- your CLASSPATH
- the source
- the EXACT error message you get when you try to compile
Capture the console output to a file then cut-and-paste into a reply.
 
S

Steve R. Burrus

Sudsy said:
1st step in problem determination: review the EXACT messages being
generated. Using a phrase such as "something like that" will not
generally prompt people to reply.
So we need to see the following:
- the EXACT error message you get when you try to compile

Okay, "Sudsy", here is the exact error msg. which I haved been getting:symbol : variable ServletUtilities
location: class coreservlets.HelloServlet3
out.println(ServletUtilities.headWithTitle(title) + ^ 1 error
Tool completed with exit code 1"<<
- the source

Okay, here is my source code :
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloServlet3 extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Hello (3)";
out.println(ServletUtilities.headWithTitle(title) +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>" + title + "</H1>\n" +
"</BODY></HTML>");
}
}"<<
- your CLASSPATH

And finally, going into my win xp Pro's System Settings, my classpath is

..;C:\jakarta-tomcat-5.0.12\common\lib\servlet-api.jar;C:\jakarta-tomcat-5.0.12\common\lib\jsp-api.jar;
C:\ServletDev;C:\j2sdk1.5.0\lib\tools.jar;C:\j2sdkee1.3.1\lib\j2ee.jar *

* i of course have all of the classpath on just 1 line "in real life" :)
 
S

Sudsy

Steve said:
Okay, "Sudsy", here is the exact error msg. which I haved been getting:

So you naturally have a file in the directory
C:\jakarta-tomcat-5.0.12\webapps\ROOT\WEB-INF\classes\coreservlets
named ServletUtilities.java and which also has the
package coreservlets;
declaration, right? And you compiled in the coreservlets subdirectory
without the -d flag?
You still seem to be missing the fundamental concept that packages map
to the directory structure. A servlet container will automatically
include the WEB-INF/classes directory in the classpath. You just have
to make sure that your classes have the correct package declaration
and sit at the correct place in the directory heirarchy.
 
J

juli

hai steve,

step 1>If u have servlet.jar file in ur java bin directory ie copy & paste
servlet jar file from tomcat lib folder

step 2> compile ur java file using the below command
javac -classpath ./servlet.jar;./server.jar\bin <filename.java>

i think this should work now u can copy ur class file to ur tomcat class
directory.
IF ABOVE STEP DOES NOT WORK
or u can set a classpath in ur enviroment variable if ur using win xp or
me ie
set CLASSPATH= C:\TOMCATFOLDER\COMMON\LIB\SERVLET.JAR
THE U CAN COMPILE UR CLASS FILE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,849
Latest member
Fira

Latest Threads

Top