Need help w. the servlet.jar file.

Discussion in 'Java' started by Steve R. Burrus, Jun 12, 2004.

  1. 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?
     
    Steve R. Burrus, Jun 12, 2004
    #1
    1. Advertising

  2. Steve R. Burrus

    Sudsy Guest

    Steve R. Burrus wrote:
    > 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.
     
    Sudsy, Jun 12, 2004
    #2
    1. Advertising

  3. Sudsy wrote:
    > 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:
    >>"C:\jakarta-tomcat-5.0.12\webapps\ROOT\WEB-INF\classes\coreservlets\HelloServlet3.java:23: cannot find symbol

    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 :
    >>"package coreservlets;


    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" :)
     
    Steve R. Burrus, Jun 13, 2004
    #3
  4. Steve R. Burrus

    Sudsy Guest

    Steve R. Burrus wrote:
    > Sudsy wrote:
    >
    >> 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:
    > >>"C:\jakarta-tomcat-5.0.12\webapps\ROOT\WEB-INF\classes\coreservlets\HelloServlet3.java:23: cannot find symbol


    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.
     
    Sudsy, Jun 13, 2004
    #4
  5. Steve R. Burrus

    juli Guest

    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
     
    juli, Jun 16, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. circuit_breaker
    Replies:
    2
    Views:
    2,091
    Jack Jia
    Apr 4, 2004
  2. Arnold Peters
    Replies:
    0
    Views:
    636
    Arnold Peters
    Jan 5, 2005
  3. muttley
    Replies:
    0
    Views:
    2,795
    muttley
    Oct 20, 2005
  4. cyberco
    Replies:
    4
    Views:
    3,874
    Roedy Green
    Feb 14, 2006
  5. Arnold Peters
    Replies:
    0
    Views:
    704
    Arnold Peters
    Jan 5, 2005
Loading...

Share This Page