Help: Compiling servlets

Hi,
I have created a servlet java file.
and when i compile the servlet java file, I am getting error,
HelloWorld.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
HelloWorld.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
HelloWorld.java:5: cannot find symbol
symbol: class HttpServlet
public class HelloWorld extends HttpServlet {
^
HelloWorld.java:7: cannot find symbol
symbol : class HttpServletRequest
location: class HelloWorld
public void doGet(HttpServletRequest req, HttpServletResponse res)
^
HelloWorld.java:7: cannot find symbol
symbol : class HttpServletResponse
location: class HelloWorld
public void doGet(HttpServletRequest req, HttpServletResponse res)
^
HelloWorld.java:8: cannot find symbol
symbol : class ServletException
location: class HelloWorld
throws ServletException, IOException {
^
6 errors
where can i get the missing javax classes?
Thanks and Regards,
Rashmy.

Hi Sreekanth,
Yes, I am using Tomcat server.
I have java SDK 6 and J2EE 5.
I am setting up the path to jdk6 and compiling it.
is this the correct way?
and i tried settingup calss path to the servlet-api.jar. but getting the same error.
Thanks,
Rashmy.

Similar Messages

  • Compiling servlet with helper class

    Hello,
    I have to write a very large number of database queries and huge amount of code so I decided to make each helper *.class file for each table.
    Now I have a main servlet that should instantiate each of these helper classes and conduct DB operations:
    //Servlet code
    RescardreservationTable rv = new RescardreservationTable();
    rv.insertInfo();
    RescardPassengerTable rp = new RescardPassengerTable();
    rp.insertInfo();RescardreservationTable.class
    //does DB opsMy problem is that when I try to compile servlet, I get
    insert_data.java:172: cannot find symbol
    symbol : class RescardreservationTable
    location: class insert_data
    RescardreservationTable rv = new RescardreservationTable();
    Could somebody please tell me how I can make servlet locate my java classes that it has to use?
    Thanks,
    Victor.
    Edited by: vic_sk on Dec 9, 2008 9:29 AM

    Ok, looks like it's solved. Just forcing the compiler with -classpath to look for the required class file.

  • Urgent help please - What files needed to compile servlets

    I am trying to compile some servlets but can't. I recently reformatted and forgot how I had configured Tomcat previously.
    What files do I need to compile servlets, and where do I have to save them etc.
    Thanks

    u will require jsdk.jar..
    put this in classpath and then compile ..it will surely compile
    and for compiling ...there is no configuration reqd in tomcat

  • 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

  • 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.

  • 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.

  • Compiling servlets

    I cant compile servlets.
    Im using tomcat and I tried to compile the servlets in the example seperately but theres always errors. However when I execute the file from the example folder it runs just nicely.
    This is an example of the error produced:
    equestInfoExample.java:22: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    RequestInfoExample.java:23: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    RequestInfoExample.java:25: package util does not exist
    import util.HTMLFilter;
    ^
    RequestInfoExample.java:33: cannot resolve symbol
    symbol : class HttpServlet
    location: class RequestInfoExample
    public class RequestInfoExample extends HttpServlet {
    ^
    RequestInfoExample.java:38: cannot resolve symbol
    symbol : class HttpServletRequest
    location: class RequestInfoExample
    public void doGet(HttpServletRequest request,
    ^
    RequestInfoExample.java:39: cannot resolve symbol
    symbol : class HttpServletResponse
    location: class RequestInfoExample
    HttpServletResponse response)
    ^
    RequestInfoExample.java:40: cannot resolve symbol
    symbol : class ServletException
    location: class RequestInfoExample
    throws IOException, ServletException
    ^
    RequestInfoExample.java:105: cannot resolve symbol
    symbol : class HttpServletRequest
    location: class RequestInfoExample
    public void doPost(HttpServletRequest request,
    ^
    RequestInfoExample.java:106: cannot resolve symbol
    symbol : class HttpServletResponse
    location: class RequestInfoExample
    HttpServletResponse response)
    ^
    RequestInfoExample.java:107: cannot resolve symbol
    symbol : class ServletException
    location: class RequestInfoExample
    throws IOException, ServletException
    ^
    RequestInfoExample.java:76: cannot resolve symbol
    symbol : variable HTMLFilter
    location: class RequestInfoExample
    out.println(HTMLFilter.filter(request.getRequestURI()));
    ^
    RequestInfoExample.java:84: cannot resolve symbol
    symbol : variable HTMLFilter
    location: class RequestInfoExample
    out.println(HTMLFilter.filter(request.getPathInfo()));
    ^
    12 errors
    why is this.
    Please someone help me here!!
    Thanks in advance.

    what ever the above steps had i done i got the same error
    httpservletrequest unable to resolve symbol
    what i made is mycomputer>properties>advaced>envirinment variables>path>C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.*;(as am i using tomcat 5)and
    in cmd prompt set classpath=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.*;and
    in cmd prompt set path=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.*;got the same result unable to resolve the symbol pls i need some ones help

  • Compiling Servlet

    Please, can someone help me with this:
    When I try compile servlet I got This error message:
    C:\jdk1.2.2\bin>javac HTTPPostServlet.java
    HTTPPostServlet.java:9: Superclass HttpServlet of class HTTPPostServlet not foun
    d.
    public class HTTPPostServlet extends HttpServlet {
    ^
    1 error
    Why it happening and how I can avoid this.
    v.

    i assume u know that we need a java Servlet Development kit 2.0 to run a servlet other than a TOMCAT Server
    If u have jsdk2.0 installed on your machine One of the solution may be to set your classpath to <installation path>:\jsdk2.0\lib\jsdk.jar
    and then compile it and u 'll see that it has no errors
    it will work

  • Compiling Servlet problem that uses a JavaBean

    I have a servlet that will get data from a JavaBean which is created before in a jsp file. While I trying to compile the servlet I am getting this message:
    --------------------Configuration: JDK version 1.3 <Default>--------------------
    Command : "C:\jdk1.3\bin\javac.exe" -d "C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes" C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\MyServlet.java
    Directory : C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes
    C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\TasitKayitGirisi.java:19: cannot resolve symbol
    symbol : class SimpleBean
    location: class MyPackage.SimpleBean
         SimpleBean simpleBean = (SimpleBean) session.getAttribute
    ^
    ("simpleBean");
    C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\MyServlet.java:19: cannot resolve symbol
    symbol : class SimpleBean
    location: class MyPackage.SimpleBean
         SimpleBean simpleBean= (SimpleBean) session.getAttribute("simpleBean");
    ^
    2 errors
    Process completed.
    Where is the problem. SimpleBean is successfully being initializing in my jsp file. But I couldn't compile my servlet that will get data from that bean. Both my servlet and bean are in the same package. I am using JCreator to compile servlets. I think the problem is the compile string that JCreator uses. Can you help me. Thx in advance.

    Hi,
    The problem is it is not finding the Bean. Put it in the classpath.
    The simplest way is put the class in /WEB-INF/classes/MyPackage folder.

  • Why we need to restart server when we compile servlet (not for jsp)

    hi
    why we need to restart server/appln when we compile servlet .
    same thing is not true for jsp
    as jsp converts to servlets then also it need not require restart of server/appln.
    Danny

    Dear Friends
    I hope you guys are doing something with tomcat , So please help me.
    can anyone solve my problem.
    I am starting my tomcat using startup and the dos window just closes after opening . I don't know why?
    The errors generated are as:
    Using CATALINA_BASE: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29
    Using CATALINA_HOME: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29
    Using CATALINA_TMPDIR: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29\temp
    Using JAVA_HOME: C:\jdk1.3.0_02
    Catalina.start: java.util.MissingResourceException: Can't find bundle for base name org.apache.coyote.tomcat4.LocalStrings, locale en_US
    java.util.MissingResourceException: Can't find bundle for base name org.apache.coyote.tomcat4.LocalStrings, locale en_US
         at org.apache.commons.digester.Digester.createSAXException(Digester.java:2540)
         at org.apache.commons.digester.Digester.createSAXException(Digester.java:2566)
         at org.apache.commons.digester.Digester.startElement(Digester.java:1276)
         at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
         at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at org.apache.commons.digester.Digester.parse(Digester.java:1548)
         at org.apache.catalina.startup.Catalina.start(Catalina.java:449)
         at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
         at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
         at java.lang.reflect.Method.invoke(Native Method)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
    Using CATALINA_BASE: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29
    Using CATALINA_HOME: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29
    Using CATALINA_TMPDIR: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29\temp
    Using JAVA_HOME: C:\jdk1.3.0_02
    Catalina.start: java.util.MissingResourceException: Can't find bundle for base name org.apache.coyote.tomcat4.LocalStrings, locale en_US
    java.util.MissingResourceException: Can't find bundle for base name org.apache.coyote.tomcat4.LocalStrings, locale en_US
         at org.apache.commons.digester.Digester.createSAXException(Digester.java:2540)
         at org.apache.commons.digester.Digester.createSAXException(Digester.java:2566)
         at org.apache.commons.digester.Digester.startElement(Digester.java:1276)
         at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
         at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at org.apache.commons.digester.Digester.parse(Digester.java:1548)
         at org.apache.catalina.startup.Catalina.start(Catalina.java:449)
         at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
         at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
         at java.lang.reflect.Method.invoke(Native Method)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
    i need your help desperately.
    I hope you will respond soon.
    thanks
    vishal

  • 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

  • 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.

  • Newbie question: how to compile servlet using tomcat?? Thank you

    How to set classpath? How to compile servlet.java?

    jsp is also converted into a servlet .java nd then into a class file
    this is index.jsp
    <%@ page contentType="text/html;charset=windows-1252"%>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>untitled</title>
      </head>
      <body>
      </body>
    </html>this is _index.java
    /*@lineinfo:filename=/index.jsp*/
      /*@lineinfo:generated-code*/
    import oracle.jsp.runtime.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    public class _index extends com.orionserver.http.OrionHttpJspPage {
      public final String _globalsClassName = null;
      // ** Begin Declarations
      // ** End Declarations
      public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException {
        response.setContentType( "text/html;charset=windows-1252");
        /* set up the intrinsic variables using the pageContext goober:
        ** session = HttpSession
        ** application = ServletContext
        ** out = JspWriter
        ** page = this
        ** config = ServletConfig
        ** all session/app beans declared in globals.jsa
        PageContext pageContext = JspFactory.getDefaultFactory().getPageContext( this, request, response, null, true, JspWriter.DEFAULT_BUFFER, true);
        // Note: this is not emitted if the session directive == false
        HttpSession session = pageContext.getSession();
        if (pageContext.getAttribute(OracleJspRuntime.JSP_REQUEST_REDIRECTED, PageContext.REQUEST_SCOPE) != null) {
          pageContext.setAttribute(OracleJspRuntime.JSP_PAGE_DONTNOTIFY, "true", PageContext.PAGE_SCOPE);
          JspFactory.getDefaultFactory().releasePageContext(pageContext);
          return;
        int __jsp_tag_starteval;
        ServletContext application = pageContext.getServletContext();
        JspWriter out = pageContext.getOut();
        _index page = this;
        ServletConfig config = pageContext.getServletConfig();
        try {
          // global beans
          // end global beans
          out.write(__oracle_jsp_text[0]);
        catch( Throwable e) {
          try {
            if (out != null) out.clear();
          catch( Exception clearException) {
          pageContext.handlePageException( e);
        finally {
          OracleJspRuntime.extraHandlePCFinally(pageContext,false);
          JspFactory.getDefaultFactory().releasePageContext(pageContext);
      private static final char __oracle_jsp_text[][]=new char[1][];
      static {
        try {
        __oracle_jsp_text[0] =
        "\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n    <title>untitled</title>\n  </head>\n  <body>\n  </body>\n</html>\n".toCharArray();
        catch (Throwable th) {
          System.err.println(th);
    }as you can see.. my IDE converts it into a java class so it can be conpiled to a class file.. by the way i use Oracle Jdeveloper 10g for this pupose of showing you what is happening to your jsp

  • Cannot compile servlet file

    I cannot compile Servlet files on my WinXP environment.
    my servlet.jar file is located at
    c:\tomcat\jakarta-tomcat-3.3.1\common\lib\servlet.jar
    what shall I do?
    The error messages are only for servlet portion of code?

    In XP you can set the path by rightclicking on my computer - then go to environment vairables and edit the path but I cannot see any for classpath???
    What is the easist way yo use the class path?

  • Unable to compile servlets

    I am unable to compile a java servlet program.
    the message thrown ou by the compiler is
    "Class java.servlet not found in import"

    You need to find where the servlet.jar file is on your system. For example i'm running tomcat on a linux machine, this is what i type to compile servlets.
    javac -classpath /var/tomcat4/common/lib/servlet.jar yourFile.java

Maybe you are looking for

  • How to change input language from english to spanish

    Hi guys, I have the British flag and Spanish flag options in top right but when I click on spainish flag and type in spanish it corrects in english. How can  make it so i can type in Spanish or English. Thanks,

  • File Making Directories Problem. java.io.FileNotFoundException

    When ever I run my program it is SUPPOSED to make the directories, instead it tells me the file doesn't exist and fails. Here is my Code: * To change this template, choose Tools | Templates * and open the template in the editor. package passworddatam

  • How to keeps track of new coming bad blocks on a hdd

    I have some 2,5 hdd lying around and wanted to test them for bad blocks and found that I can use Badblocks for this. But how do I keep the "list" of bad blocks up-to-date if new bad blocks are detected, or is this not posseble? Solixxx Last edited by

  • Upgraded the operating system on my iPad from iOS 4.x.x to the latest iOS 7.4.x.

    Before upgrading did all the right things like backing up all the apps etc onto iTunes on my home PC.  However when I came to restart the iPad after th software update it will not let me restore anything and comes up with an error message becuase it

  • Looking for Sendmail PL/SQL Package

    Hi All, I am looking for a way to call Sendmail directly from a PL/SQL Procedure. Can someone point me in a direction where I can find some PL/SQL or Pro*C Code that could do this? Thanks, Scott Walton null