I can't compile servlets

Please ignore my previous Thread.
Where do you get the nessecary libaries to compile servlets, and what directory of the JSDK1.4.0/ directory do you put them in (Im using Win98se)

File To Compile:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloClientServlet extends HttpServlet
     protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
     res.setContentType("text/html");
     PrintWriter out = res.getWriter();
          out.println("<HTML><HEAD><TITLE>Hello Client!</TITLE>"+
     "</HEAD><BODY>Hello Client!</BODY></HTML>");
          out.close();
     public String getServletInfo()
          return "HelloClientServlet 1.0 by Stefan Zeiger";
Error Messages:
C:\ServletDevelopment\HelloClientServlet.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
C:\ServletDevelopment\HelloClientServlet.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
C:\ServletDevelopment\HelloClientServlet.java:4: cannot resolve symbol
symbol : class HttpServlet
location: class HelloClientServlet
public class HelloClientServlet extends HttpServlet
^
C:\ServletDevelopment\HelloClientServlet.java:6: cannot resolve symbol
symbol : class HttpServletRequest
location: class HelloClientServlet
     protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
^
C:\ServletDevelopment\HelloClientServlet.java:6: cannot resolve symbol
symbol : class HttpServletResponse
location: class HelloClientServlet
     protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
^
C:\ServletDevelopment\HelloClientServlet.java:6: cannot resolve symbol
symbol : class ServletException
location: class HelloClientServlet
     protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
^
6 errors
Tool completed with exit code 1

Similar Messages

  • Can I compiler servlet with java compiler?

    Can I compiler servlet with java compiler?
    Here is an example of it:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class HelloWorldServlet extends HttpServlet
              protected void doGet(HttpServletRequest request,
              HttpServletResponse response) throws ServletException , IOException
                        response.setContentType("text/html");
                        PrintWriter out = response.getWriter();
                        StringBuffer sb = new StringBuffer();
                        sb.append("<html><body><h1>");
                        sb.append("Hello World");
                        sb.append("</h1></body></html>");
                        out.print(sb.toString());
                        out.close();
         }

    Can I compiler servlet with java compiler?
    yes.
    just include the correct jarfiles in your classpath.

  • I have jsdk2, but I can't compile servlet program

    I have jsdk2 version. which create in my c:\ dirve a folder jdk1.3. I do all the program from that. But I found that some of the class files of Servlet (servletRespose etc ) is missing. What I do to recover that. Even I can't compile any servlet program from that. Pls reply to my problems.
    Regards.
    Ranjan

    The Servlet API is part of J2EE (Java 2 Enterprise Edition). It is not included in the Standard Edition.
    So you need to download and install the J2EE reference implementation or another servlet engine such as Apache Tomcat ( http://jakarta.apache.org/tomcat ). Don't forget to put the Tomcat JAR files in your CLASSPATH when compiling your servlet program.
    Jesper

  • I can't compile servlets, either

    I am following the instruction of Java tutorial in
    "http://developer.java.sun.com/developer/onlineTraining/J2EE/Intro2/servlet/servlet.html". I copied the code for BonusCalculationServlet on my computer and tried to compile it but i couldn't. The error message it could not recognized all the javax package classes (javax.servlet...). I installed j2 ee sdk 1.3.1 and j2se 1.4.0. I set all the environmental variable correctly and i did set classpath correctly ( classpath = %J2EE_HOME%/lib/j2ee.jar).
    If i use jsdk2.1(jdk1.2.1 servlet extension) then I can compile it. Can anybody help with this. Thanks

    You need to install a servlet runner such as Tomcat and check out Apache Jakarta-Ant for performing your builds.
    http://jakarta.apache.org/tomcat/
    http://jakarta.apache.org/ant/
    Tomcat has a great little Application Developer Guide. Check that out here:
    http://jakarta.apache.org/tomcat/tomcat-4.1-doc/appdev/index.html
    And check out a pre-assembled Ant build sample here:
    http://jakarta.apache.org/tomcat/tomcat-4.1-doc/appdev/sample/
    Once you have Tomcat-4.1.10 set up, make appropriate changes to paths in the sample build file to match your system, drop your servlet classes into the "src" directory creating whatever package directory structure you need inside that and then just go to the command line and type:
    ant compile
    Your classes will now have been compiled and you will have your WAR structure all set to deploy to Tomcat.
    Jake

  • Can't compile Servlet program(error in setting classpath in XP)

    I encountered a similar problem as 'hereispaddy'.
    "I have recently written a servlet program. When I compile the program (let's say "HelloWorld.java"), I've got the following error message:
    package javax.servlet does not exist
    I've download the class files and set the classpath already. Have I missed anything? "
    i would like to ask, how to set the following in Windows XP:
    set CATALINE_HOME=C:\PROGRA~1\APACHE~1.0
    set CLASSPATH=.;%CATALINE_HOME%\COMMON\LIB\SERVLET.JAR;C:\JDK1.4\BIN;
    *ive tried in control panel->system->advanced->environment variables->
    variable name:CATALINE_HOME
    variable value:C:\Program Files\Apache Tomcat4.0 (and)
    variable name:CLASSPATH
    variable value:.;%CATALINE_HOME%\common\lib\servlet.jar;C:\jdk1.4\bin
    but failed!
    Could anyone kindly tell me what's wrong with my setting?
    Thx a lot!!!

    Does Tomcat work? Can run the examples on the home page?
    The only suggestion I have at this point is to get rid of the spaces in
    C:\Program Files\Apache Tomcat4.0
    But I am still in Win98 , so I am just guessing.

  • How can I compile servlets?  I'm still having problems...

    Ok, I've installed J2SE and it's been working perfectly using command-line compiling (javac) and also with the Eclipse IDE.
    Now I want to start using Servlets and JSP so I installed the JWSDP (Java Web Services Developer Pack). I couldn't quite figure it out, so I installed J2EE on top of everything.
    Eclipse doesn't recognize "import javax.servlet.*;" and neither does the command-line compiler javac.
    Am I doing something wrong?

    I don't know anything about ServletExec or how it expects you to deploy a Web app. You're on your own there. I don't know if ServletExec supports WAR files or even follows the specifications for directory structures.
    Look, there are two separate issues here: compiling and running.
    Whatever you do, however you do it, you've got to have a JAR in your CLASSPATH that has the javax.servlet and javax.servlet.http packages in it when you compile. You don't need the whole J2EE app server, just the JAR with those packages.
    When you deploy and run the app, you'll do it on the server. It'll have the appropriate JARs.
    To me, app server and J2EE are synonymous. Yes, the j2ee.jar comes with Sun ONE if that's what you've downloaded.
    You can use Tomcat, which is a free servlet/JSP engine. I believe that Sun ONE has Tomcat bundled inside. If so, it'll have the servlet.jar in there somewhere. Tomcat stores it in TOMCAT_HOME/common/lib.
    MOD

  • Can't compile Servlets in J2EE 1.4 SDK 5.0

    Hi,
    I downloaded J2EE 1.4 SDK 2005Q2 UR2 which has J2SE 5.0 and has built in support for Java Servlet implementation. But when I try to complie a Servlet, compiler cribs javax.serlet.* package can't be found.
    Some solutions suggested on this forum direct one to include j2ee.jar or servlet.jar in the classpath. I have added j2ee.jar in the classpath but still the same thing happens. And there's no servlet.jar in this instalation.
    Any pointers???

    Hi,
    I downloaded J2EE 1.4 SDK 2005Q2 UR2 which has J2SE
    5.0 and has built in support for Java Servlet
    implementation. But when I try to complie a Servlet,
    compiler cribs javax.serlet.* package can't be
    found.You realize, of course, that you misspelled "servlet" - you left out the 'v'. Check your code.
    Some solutions suggested on this forum direct one to
    include j2ee.jar or servlet.jar in the classpath. I
    have added j2ee.jar in the classpath but still the
    same thing happens. And there's no servlet.jar in
    this instalation.Right. servlet.jar is for Tomcat 4.x and earlier; it's servlet-api.jar for Tomcat 5.x and later. J2EE reference app server uses j2ee.jar.
    Did you ever think to open the JAR and make sure that the package was inside? Might be worth doing instead of taking it on faith. If you can't find it, the class loader won't, either.
    Any pointers???See above. If that's not it, you think you have the JAR in your CLASSPATH but you don't. Don't argue with the compiler. Figure out what YOU did wrong.
    %

  • I FOUND : servlet-api.jar ...WHERE insert it to can compile SERVLETS

    I FOUND : servlet-api.jar in TOMCAT 6
    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

    You can use any of the following methods:
    i) SET CLASSPATH variable with absolute path of your servlet-api.jar and then compile your servlet from any folder.
    ii)you can use
    C:\jdk\bin>javac -cp C:\tomcat\lib\servlet-api.jar SampleServlet.javaand after comilation put the compiled java class file to classes folder of you web application.
    [Obviously if you have any package, then you need to maintaing that folder structure inside classes folder]
    Here I assumed your javac is available at C:\jdk\bin folder and servlet-api.jar is available at C:\tomcat\lib folder
    ---Sujoy

  • Unable to compile servlet files in javac

    i am unable to compile servlet *.java files in javac.as far as i can see my path is correct.
    Kindly provide a solution as soon as possible.
    My jdk1.3 is in my c drive and my tomcat in my d drive.
    if you are able to compile kindly let me know your path.
    it says symbol not resolved.i think that it is unable to import from javax

    Assuming that your jdk is in c drive as c:\jdk1.3 set the path and the classpath like as shown below. Remember that you have to set the classpath for the classes in the javax.servlet and javax.servlet.http packages. I know how to do it for JavaWebServer. JavaWebServer has a jar called servlet.jar that contains all these classes. What you need to do is to put this jar file in your classpath. There will be a similar jar file for Tomcat server also. You need to refer the Tomcat server documentation for that.
    The path and the classpath have to be set like this...
    d:\>path=%path%;.;c:\jdk1.3\bin;
    d:\>set classpath=%classpath%;.;c:\jdk1.3\lib;c:\JavaWebServer2.0\lib\servlet.jar;
    assuming tht JWS is installed in c:\JavaWebServer2.0
    Also note that there should be no spaces in between while setting the classpath. In your case you have to change the last part of the classpath to customize your requirement.
    Hope that will help.
    Regards
    Jaydeep

  • How do you set up your system to compile servlets?

    I can't compile my servlets. I need the javax.servlet packages. I went to java.sun.com/products/servlet but couldn't find the servlet SDK. Is it now all wrapped up in the J2EE SDK?
    So I downloaded the J2EE beast and put j2ee.jar in my C:\JDK1.3\jre\lib\ext. Now I can compile my servlets fine from the command line. But now Tomcat doesn't work at all. Even when I try to run the servlets that are supplied in the examples with Tomcat, I get the following errors:
    Internal Servlet Error:
    javax.servlet.ServletException: sun/tools/javac/Main
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:415)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
         at org.apache.tomcat.core.Handler.service(Handler.java:287)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
         at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
         at java.lang.Thread.run(Thread.java:484)
    These errors disappear if I remove j2ee.jar
    So, how shoudl I configure my system so taht I can run Tomcat and also compile my servlets from the command line ? Also, do I really have to keep restarting Tomcat each time I want to reload a servlet ?

    To set up Tomcat, here's what I'd do.
    1) Remove j2ee.jar from C:\JDK1.3\jre\lib\ext
    That will cause more headaches than you can imagine.
    2) Add servlet.jar to your classpath. Servlet.jar is located in lib under your tomcat directory. ( so, something like C:\jakarta-tomcat\lib\servlet.jar )
    3) Make sure that you have your JAVA_HOME environment variable set to C:\JDK1.3. If this is not set up correctly then you will get the error: sun/tools/javac/Main not found...
    Hope that helps.
    Anne

  • Not Able to compile Servlet from ?

    Hi All,
    I am not able to compile Servlet from my package:
    1) I Have set the CLASSPATH Variable using below line in System Variables:
    C:\CC4\prog\jakarta-tomcat-4.1.30\common\lib\servlet.jar
    2) Also Set the CATALINA_HOME with value
    C:\CC4\prog\jakarta-tomcat-4.1.30
    as per above setting servlet should be compiled but still i m getting error message:
    1) C:\CC4\prog\jakarta-tomcat-4.1.30\project\classes\com\example>javac ListenerTest
    er.java
    ListenerTester.java:17: cannot resolve symbol
    symbol : class Dog
    location: class com.example.ListenerTester
    Dog dog = (Dog) getServletContext().getAttribute("dog");
    ^
    ListenerTester.java:17: cannot resolve symbol
    symbol : class Dog
    location: class com.example.ListenerTester
    Dog dog = (Dog) getServletContext().getAttribute("dog");
    ^
    2 errors
    2) Error while compiling other file:
    C:\CC4\prog\jakarta-tomcat-4.1.30\project\classes\com\example>javac MyServletCon
    textListener.java
    MyServletContextListener.java:12: cannot resolve symbol
    symbol : class Dog
    location: class com.example.MyServletContextListener
    Dog d = new Dog(dogBreed);
    ^
    MyServletContextListener.java:12: cannot resolve symbol
    symbol : class Dog
    location: class com.example.MyServletContextListener
    Dog d = new Dog(dogBreed);
    ^
    2 errors
    So what could be the posible solution here :
    do reply !!!
    please
    Thanks
    prabhat

    I have added servlet.jar in the classpath. But the program is not compiling.The error message says that it can not find classes like ServletConfig, ServletException, Cookie etc. Please help.

  • Trouble compiling Servlets... simple problem?

    PATH: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\PROGRA~1\ULTRAE~1;C:\j2sdk1.4.0\bin;C:\j2sdkee1.3.1\bin
    CLASSPATH: C:\j2sdkee1.3.1\lib\j2ee.jar;C:\j2sdkee1.3.1\lib\j2eetool.jar
    Yet for some reason I can't compile anything using the servlet packages. I had been able to compile in the past, but I added a new value to the PATH and CLASSPATH variables to try to get Tomcat4.0.1 to work, and then this morning I ceased to be able to compile. So I went back to my old values and can't compile! (DataServlet.java:3: package javax.servlet does not exist
    import javax.servlet.*; )
    Please help. Thank you.

    Ok, I just wrote this post, closed the command prompt I was trying to compile in, reopened another, and tried to compile again and it worked. Can someone tell me what this is about?

  • Getting error in compiling servlet

    I am trying to compile servlet and I am getting error "cannot resolve symble : class HttpServlet"
    there are 6 error almost same not resolve servlet or http. I already add jdk1.3.1 and tomcat in my path I don't understand why I am getting this error please help me.

    You need to add servlet.jar into the classpath. You can find servlet.jar in tomcat_home\lib dir.

  • I can't compile this, why?

    I do not possess any means of compiling any .java file that imports javax.* or anything J2SE-related, thus, I have to compile it remotely on a remote host (www.myjavaserver.com), however, for some reason this file will not compile but will not produce any errors, warnings, or any display of any kind - but no .class file is ever found.
    import java.io.*, java.util.*, javax.servlet.*, javax.servlet.http.*;
    * Borrowed from http://forum.java.sun.com/thread.jspa?threadID=703076
    * @access public
    * @author Phil Powell
    public class RequestParameterResetter extends HttpServletRequestWrapper {
        private HttpservletRequest origRequest;
        private Map<String, String> parameterMap;
        public RequestParameterResetter(HttpServletRequest request) {
            super(request);
            origRequest = request;
            parameterMap = new HashMap<String,String>();
        public String setParameter(String key, String value) {
            String oldValue = parameterMap.put(key,value);
            if (oldValue == null) oldValue = origRequest.getParameter(key);
            return oldValue;
        public String getParameter(String key) {
            String value = parameterMap.get(key);
            if (value == null) value = origRequest.getParameter(key);
            return value;
    }Could someone tell me what I'm missing in order for this to properly compile?
    Thanx
    Phil

    Sorry I can't do that, as much as I want to. My
    computer is very ancient and has too little memory to
    run any kind of server program, especially a
    Java-related one. I tried with Eclipse a while back
    (2 years ago and never figured it out, way too hard
    in spite of my PC's inability to interact with it)
    nearly destroyed my machine with it.You actually don't need to run any server. You just need to get the .JAR files (you should try to get the same server and version that you deploy on ... but that may not be possible). Then you put them in your Java Classpath, and you will be able to compile (from command line, or whatever). You could then un-install the server if you wanted to...
    >
    That means I can only compile J2SE formatted classes
    remotelyThat would be J2EE. J2SE is the standard edition, where you get the compiler, java.lang.String, java.util.Date, and all the rest of the core stuff. J2EE is the enterprise edition for getting the javax.servlet packages (among others).
    More comments on how you might change added as comments in the code...
    on www.myjavaserver.com - provided it is
    working.
    I made the changes necessary and still can't compile
    it!
    package ppowell;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    * Borrowed from
    m
    http://forum.java.sun.com/thread.jspa?threadID=703076
    * @version JSDK 1.2
    The class is a Java 5.0 class, it won't compile to JSDK 1.2.
    Ask myjavaserver.com to see how you can get ahold of the error logs so you can see what messages are generated.
    * @author Phil Powell
    * @package PPOWELL
    public class RequestParameterResetter extends
    HttpServletRequestWrapper {
    private HttpServletRequest origRequest;
    private Map<String, String> parameterMap;//if you want to use non JSE 5.0, then this line should be:
    //        private Map parameterMap;
    >
    public
    blic RequestParameterResetter(HttpServletRequest
    request) {
    super(request);
    origRequest = request;
    parameterMap = new HashMap<String,String>();//if you want to use non JSE 5.0, then this line should be:
    //            parameterMap = new HashMap();
    public String setParameter(String key, String
    ring value) {
    String oldValue = parameterMap.put(key,value);//if you want to use non JSE 5.0, then this line should be:
    //        String oldValue = (String) parameterMap.put(key,value);
    if (oldValue == null) oldValue = origRequest.getParameter(key);
    return oldValue;
    public String getParameter(String key) {
    String value = parameterMap.get(key);//if you want to use non JSE 5.0, then this line should be:
    //            String value = (String)parameterMap.get(key);
    if (value == null) value =
    value = origRequest.getParameter(key);
    return value;

  • Can't compile this sourcecode

    why i can't compile this source code??
    if i not mistaken the error like this "can't read bla..bla(i din't remember)"
    (i've install all the java package..)
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.Date;
    import java.util.Hashtable;
    * Date Servlet
    * This is a simple servlet to demonstrate server-side include
    * It returns a string representation of the current time.
    * @author Scott Atwood
    * @version 1.12, 08/29/97
    public class DateServlet extends HttpServlet {
    public void service(HttpServletRequest req, HttpServletResponse res)
         throws ServletException, IOException
    Date today = new Date();
    res.setContentType("text/plain");
    //getOutputStream ni aper?
    ServletOutputStream out = res.getOutputStream();
    out.println(today.toString());
    public String getServletInfo() {
    return "Returns a string representation of the current time";

    Try it again. And this time write down the error message you get so you can ask a coherent question.

Maybe you are looking for

  • Content Server Check-in

    Dear All, Good day, I need help regarding content profiles for content server, I want to know if I can create a specific metadata filed related to specific area such as HR (empno, emp name, department, job title....etc), I don't want to make all the

  • Problem with JSObject.getWindow() method - Please Help

    I have a small Apllet that has a button that calls a Javascript function in the opening window, to close the window in which it is loaded. The Applet window is a PopUp window from one of my application's window. First time I start my application and

  • APEX 4: template copy function in tree view working as expected?

    Not sure if this is the intended design or not (doesn't seem like it should be, to me). When you are in the edit page screen (4150) - in tree-view mode, you have shared components and templates on the far right. Say you want to copy one, you have the

  • CCMS Background Job Monitoring

    We have setup CCMS background job monitoring and use it to send alerts for failed CH_* jobs. We activated an autoreaction for Job_Monitoring_Status. Our autoreaction method has some extra functions to suppress duplicate alerts. It uses the alert text

  • Spotlight crashing finder

    Got some weird crashes when searching a drive for files today. Happened 6 times while searching for about 50 files. Any idea why? 1/21/12 8:30:15 PM com.apple.launchd.peruser.502[3199] (com.apple.Finder[5599]) Job appears to have crashed: Abort trap