Results 1 to 8 of 8
  1. #1
    Join Date
    May 2007
    Posts
    139

    Unanswered: when I went to compile Servlets I get error below, where is the wrong

    I install JDK but when I went to compile Servlets I get error below, where is the wrong ? I compile/run success normal java...

    Code:
    C:\J-DB-ACCESS\Servlets-JSPs\Chapter9\WEB-INF\classes>javac Test21.java
    
    C:\J-DB-ACCESS\Servlets-JSPs\Chapter9\WEB-INF\classes>java Test21
    String test: str = hello
    
    C:\J-DB-ACCESS\Servlets-JSPs\Chapter9\WEB-INF\classes>cd C:\J-DB-ACCESS\Servlets-JSPs\Chapter9
    
    C:\J-DB-ACCESS\Servlets-JSPs\Chapter9>javac HelloPlantServlet.java
    HelloPlantServlet.java:4: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    HelloPlantServlet.java:5: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    HelloPlantServlet.java:7: cannot find symbol
    symbol: class HttpServlet
    public class HelloPlantServlet extends HttpServlet   {
                                           ^
    HelloPlantServlet.java:10: cannot find symbol
    symbol  : class HttpServletRequest
    location: class HelloPlantServlet
       protected void doGet( HttpServletRequest request, //Executes in response to a "get" public
                             ^
    HelloPlantServlet.java:11: cannot find symbol
    symbol  : class HttpServletResponse
    location: class HelloPlantServlet
           HttpServletResponse response )               //type of request from a Web client.
           ^
    HelloPlantServlet.java:12: cannot find symbol
    symbol  : class ServletException
    location: class HelloPlantServlet
             throws ServletException, IOException
                    ^
    6 errors
    
    C:\J-DB-ACCESS\Servlets-JSPs\Chapter9>

  2. #2
    Join Date
    May 2007
    Posts
    139
    Also the below what make it ? may not DSN working(localhost) in servlet or bad combilation or old java deprecated ? :

    HTTP Status 404 - /flowerpowerget
    --------------------------------------------------------------------------------
    type Status report

    message /flowerpowerget

    description The requested resource (/flowerpowerget) is not available.
    --------------------------------------------------------------------------------
    Apache Tomcat/6.0.18

  3. #3
    Join Date
    Oct 2002
    Location
    Baghdad, Iraq
    Posts
    697
    javac issues: Your CLASSPATH variable isn't set correctly.

    apache issues: 404 means the resource isn't available. What resource did you expect to be there?

  4. #4
    Join Date
    May 2007
    Posts
    139
    "javac issues: Your CLASSPATH variable isn't set correctly." EVENT IF NORMAL JAVA COMPILES WELL LIKE
    import java.sql.*;
    import java.io.*;
    I THINK ONLY servlet IMPORTS GIVE ERROR AND SOME servlet CLASSES, WELL ?
    Other matter solved ...

  5. #5
    Join Date
    Sep 2009
    Posts
    44
    Quote Originally Posted by lse123 View Post
    "javac issues: Your CLASSPATH variable isn't set correctly." EVENT IF NORMAL JAVA COMPILES WELL LIKE
    import java.sql.*;
    import java.io.*;
    I THINK ONLY servlet IMPORTS GIVE ERROR AND SOME servlet CLASSES, WELL ?
    Other matter solved ...
    Java is searching for the servlet classes and it is not finding them.

    Code:
    package javax.servlet.http does not exist
    This means that with every entry in CLASSPATH, java looked to see if it could find entry/javax/servlet/http. It looked inside any .jar files listed. It probably also looked in some default location, which is how it found the standard packages java.sql.* and java.io.*.

    That's just how it works. You need to figure out where the servlet classes are and set your CLASSPATH variable to include them.

    They ought to already be in your classpath. A common problem is if you have multiple JVMs installed. You have, guaranteed, 2 since you have a JRE and a JDK, probably more, and some OSs ship with 4 or 5 installed.

    It is a huge pain in the butt, but you need to figure it out if you're going to use Java to do stuff. (Just about every language has some variant of this problem, incidentally.) Google "problem with classpath"; you're not the only one with this problem.

  6. #6
    Join Date
    May 2007
    Posts
    139
    I FOUND : servlet-api.jar in TOMCAT 6 (THIS ONLY NEEDED CORRECT?)
    WHERE insert it to can compile SERVLETS ?

    where added(directory), some folders follow...?

    C:\Program Files\Java\jdk1.6.0_15\bin
    C:\Sun\AppServer\lib
    C:\Program Files\Java\jdk1.6.0_15\src\javax

  7. #7
    Join Date
    May 2007
    Posts
    139
    I FOUND : servlet-api.jar in TOMCAT 6 (THIS ONLY NEEDED CORRECT?)
    C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.18\lib\servlet-api.jar

    WHERE insert it(FOLDER) to can compile SERVLETS ?


    TO set classpath in System Vars what to insert ? currently is:
    .;C:\Program Files\Java\jre6\lib\ext\QTJava.zip

    another way is to copy servlet-api.jar to directory is servletsample.java (and this DIR USED TO COMPILE)?

  8. #8
    Join Date
    Apr 2008
    Location
    Bangalore, India
    Posts
    27

    Classpath needs to be updated

    Some pointers to the classpath problem:
    1. Ensure that you have downloaded JDK/J2EE and installed
    2. Make sure that your PATH variable is set to the correct JAVA folder, the system default java installation may not contain servlet jars.
    3. Set your CLASSPATH=%PATH%;<j2ee_directory/lib>/servlet-2.2.jar
    --
    Girish.B
    Lytecube.com
    code free application environments

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •