Cannot fing the javax.servlet.*; package

Hi everybody.. I am new to J2EE Programming.. I just wrote a very small and simple Servlet to see how it works.. The Servlet is designed to take in the the name and a favourite color of a user via a HTML page and display it to him
Here is the code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class VerifyData extends HttpServlet
     public void doGet (HttpServletRequest reg, HttpServletResponse res) throws ServletException, IOException
          res.setContentType("text/html");
          PrintWriter out = res.getWriter();
          String name= req.getParameter ("name");
          String color=req.getParameter ("color");
          out.println("<html>");
          out.println("<head>");
          out.println("<title>Simple HTML Form</title>");
          out.println("<link rel='styleSheet' type='text/css' href='examples.css'>");
          out.println("</head>");
          out.println("<body>");
          out.println("<h1>Hello "+name+" Your favourite Color is : " +color+"</h1>");
          out.println("<form method='GET' action='verifydata'>");
          out.println("<p>Please Type in your name here:</p>");
          out.println("<input type='text' name='name'>");
          out.println("<p>Now select the color of your choice</p>");
          out.println("<select name='color' size='1'>");
          out.println("<option>red<option>green<option>blue</select>");
          out.println("<br></br>");
          out.println("<input type='submit'>");
          out.println("<br></br>");
          out.println("<table>");
          out.println("<tr><th>Colors</th><th>Description</th></tr>");
          out.println("<tr><td>Red</td><td>Blood</td></tr>");
          out.println("<tr><td>Green</td><td>Grass</td></tr>");
          out.println("<tr><td>Blue</td><td>Sky</td></tr>");
          out.println("</table>");
          out.println("</form>");
          out.println("</body>");
          out.println("</html>");
}BUT I got the following Error:
C:\Sun\AppServer\jdk\bin>javac VerifyData.java
VerifyData.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
VerifyData.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
VerifyData.java:5: cannot find symbol
symbol: class HttpServlet
public class VerifyData extends HttpServlet
                                ^
VerifyData.java:7: cannot find symbol
symbol  : class HttpServletRequest
location: class VerifyData
        public void doGet (HttpServletRequest reg, HttpServletResponse res) thro
ws ServletException, IOException
                           ^
VerifyData.java:7: cannot find symbol
symbol  : class HttpServletResponse
location: class VerifyData
        public void doGet (HttpServletRequest reg, HttpServletResponse res) thro
ws ServletException, IOException
                                                   ^
VerifyData.java:7: cannot find symbol
symbol  : class ServletException
location: class VerifyData
        public void doGet (HttpServletRequest reg, HttpServletResponse res) thro
ws ServletException, IOException
   ^
VerifyData.java:11: cannot find symbol
symbol  : variable req
location: class VerifyData
                String name= req.getParameter ("name");
                             ^
VerifyData.java:12: cannot find symbol
symbol  : variable req
location: class VerifyData
                String color=req.getParameter ("color");
                             ^
8 errors
C:\Sun\AppServer\jdk\bin>Please please please help me out. I am not sure about the class path settings etc.. but its like this C:\Sun\AppServer\jdk\lib\tools.jar

Hi everybody
I am new to j2ee.I am using java ee5.Application server as apache-tomcat-5.5.17.I tried to compile servlet using javac.it gives the following errors.
HelloServlet2.java:4: package javax.servlet does not exist
import javax.servlet.*;
^
HelloServlet2.java:5: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
HelloServlet2.java:15: cannot find symbol
symbol: class HttpServlet
public class HelloServlet2 extends HttpServlet {
^
HelloServlet2.java:16: cannot find symbol
symbol : class HttpServletRequest
location: class coreservlets.HelloServlet2
public void doGet(HttpServletRequest request,
^
HelloServlet2.java:17: cannot find symbol
symbol : class HttpServletResponse
location: class coreservlets.HelloServlet2
HttpServletResponse response)
^
HelloServlet2.java:18: cannot find symbol
symbol : class ServletException
location: class coreservlets.HelloServlet2
throws ServletException, IOException {
^
6 errors
this is the code
public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n";
out.println(docType +
"<HTML>\n" +
"<HEAD><TITLE>Hello (2)</TITLE></HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>Hello (2)</H1>\n" +
"</BODY></HTML>");
pls help me to resolve this problem.
Thank you
sam

Similar Messages

  • How do I get the javax.servlet package?

    I have a simple question. I downloaded the JAVA platform Standard Edition SDK 1.6.0 and find that it doesn't have the javax.servlet package? From where can I get it and how to install and configure?

    hi,
    you don't have servlet in J2SE... you can get it
    from J2EE ... download the latest J2EE .. the
    package is available in j2ee.jar file..
    ou can download it from:
    http://java.sun.com/javaee/downloads/index.jsp
    -- Abdel Raoof Olakara
    http://olakara.googlepages.com
    You are quite wrong my friend... Servlets don't depend on any J2EE container, the only thing you need is a J2SE edition... check this:
    http://en.wikipedia.org/wiki/Java_Servlet
    MeTitus

  • Development kit which includes the javax.servlet package

    Which java development kit(s) contain the javax.servlet package.v I can't seem to find one. Thanks

    You might want to ask this on the Java forum - but if you want to run a servlet you need a Java EE server - something like Glassfish or WebLogic or Tomcat.
    The Java forums are here:
    https://forums.oracle.com/forums/category.jspa?categoryID=285
    Right now you are in the JDeveloper forum - and by the way, if you download JDeveloper you'll get everything you need to develop and test run your servlet.

  • Getting javac to find javax.servlet package

    Hey all. I'm trying to get Servlets to run on my computer. I'm using jdk1.4, it didn't have the javax.servlet package to start off with. I downloaded jsdk2.0, which includes the javax.servlet package. I can't get the javac compiler to find these classes no matter what I do, I copied the entire javax/servlet folder into the jdk1.4/src.zip file that seemed to have all the other import files, I copied the jsdk.jar file into jdk1.4/lib/ folder, that didn't work either. In my batch file that sets the path for jdk, I added set classpath = c:\jsdk2.0\lib\jsdk.jar and that didn't work. I really can't seem to get javac to find these classes. Any help is greatly appreciated!

    The above advice is incorrect and can lead you to many problems.
    You should have nothing in your CLASSPATH environment variable immediately after installing J2SDK 1.4.1.
    You then have to install the Servlet API by pointing your CLASSPATH env. var. to it. To do this depends on the version of the Servlet spec. that you have as some of the olders ones were distributed as jar files, and the latest I believe is a set of classes to be extracted.
    At the end of the day, you must point your CLASSPATH to the Servlet API. Read up on how to set the CLASSPATH. Also, don't forget to include the current working directory (.) in your CLASSPATH after manually setting it.
    Good luck !!
    Tony Morris
    Software Engineer, IBM
    Gold Coast, Australia

  • Compiling Servlets: javax.servlet package unknown

    Hello everybody,
    I'm new to J2EE technology and would like to start with creating servlets, but the javac compiler can not compile my java class succesfully, cos' it seems, it does not know the javax.servlet package.
    In each documentation is just a sentence: run javac ... But it does not work.
    Do I have to have some special configuration? I also downloaded the J2EE SDK, but the problem resisted.
    Help me, please!
    Thanx, Peter

    Hi peter,
    If you have installed the J2EE SDK 1.4, you would find $INSTALL_ROOT/lib/j2ee.jar (INSTALL_ROOT means the installation directory of J2EE SDK). PLease keep this j2ee.jar in the classpath and compile, things would be fine.
    regards
    sankar

  • Cannot find javax.servlet package

    I have just downloaded and installed the latest JEE SDK having installed Tomcat on a Linux box so that I can start getting to know JSP.
    I am following an example in a book I have for this Servlet...
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.IOException;
    public class BasicServlet extends HttpServlet {
         public void doGet (HttpServletRequest req, HttpServletResponse res)
              throws IOException {
              ServletOutputStream out = res.getOutputStream();
              res.setContentType("text/html");
              out.println("<html><head><title>Basic Servlet</title></head>");
              out.println("<body>Hello World</body></html>");
    I am using Textpad to write and compile my java and when I try to compile I get errors basically saying that it cannot find the first 2 packages I am trying to import (it manages to find the IOException fine)
    Any ideas why? I suspect that the servlet package is not in the classpath but I do no know where the package is in order to add it to my class path.
    many thanks

    I have just downloaded and installed the latest JEE
    SDK having installed Tomcat on a Linux box so that I
    can start getting to know JSP.
    I am following an example in a book I have for this
    Servlet...
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.IOException;
    public class BasicServlet extends HttpServlet {
    public void doGet (HttpServletRequest req,
    , HttpServletResponse res)
              throws IOException {
              ServletOutputStream out = res.getOutputStream();
              res.setContentType("text/html");
    out.println("<html><head><title>Basic
    ic Servlet</title></head>");
              out.println("<body>Hello World</body></html>");
    I am using Textpad to write and compile my java and
    when I try to compile I get errors basically saying
    that it cannot find the first 2 packages I am trying
    to import (it manages to find the IOException fine)
    Any ideas why? I suspect that the servlet package is
    not in the classpath but I do no know where the
    package is in order to add it to my class path.
    many thanksHave u included your servletapi.jar into classpath
    If u havnt . set classpath to point to servletapi.jar
    if it helps .. release dukes.
    sudhir nimavat
    http://www.jyog.com

  • Using Javax.Servlet package for the first time

    Hello everyone.
    I have (to some) the dumbest question, however I am new to this side of Java.
    I'm trying to create my first Servlet page, and I have Java 2 Standard edition (JDK1.3). I also have JBuilder (JDK1.3.1).
    My class seems to be unable to find the javax.Servlet.* packges.
    It seems I don't have the package available to my compiler, so I cannot compile my application.
    Someone please point me in the right direction.
    Thanks
    Rich

    you would also need to have a servlet runner. you could use tomcat jakarta.apache.org (it's the standard implementation for servlets). With Tomcat also comes the servlet package.

  • Javax.servlet package

    hi i am using netbeans but i want to deploy some servlets in my mobile application but i am getting problem in accessing javax.servlet package. can anyone tell me where can i get this one. my application is stuck now ......plz reply me fast...... i search a lot i got the specs of it but not the api.

    I wonder what you're trying to do.
    In my case, I have installed Tomcat 5.0. This installation included a jar file containing the different servlet classes I need to develop servlets. This jar file is in the folder C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib.
    I did not need to move the jar files from Tomcat to the folder of my J2SDK.
    But I had to add en environment variable under Windows XP, namely CATALINA_HOME to let the computer know where the folder of Tomcat was. With this variable, the jar file containing the classes for servlet programming can be found.

  • Cannot access directory javax/servlet

    I am having a problem getting started here with Borland JBuilder 8 SE.
    I have Tomcat installed and it runs fine with the servlets/jsp pages I ran from the index page when you first install Tomcat.
    I am running windows 2000. When I installed JBuilder the Java 2 SDK v1.4.1 was installed with it. I have run applets... java.exe is located in the jbuilder folder, don't know if this is a problem. I have set my JAVA_HOME environment variable to point to the bin folder in the 1.4.1 java.exe location.
    I am following a book that works with servlets and jsp primarily. When I typed in my first servlet that I copied from the book, JBuilder gives me a document location error:
    cannot access directory: javax/servlet at line...
    it is pointing to my import statement: "import javax.servlet.*;" and "import javax.servlet.http.*;".
    I have tried to add the servlet.jar file to my project but the results are the same.
    Can anybody give me a hand?
    thanks,
    Rob

    The fastest way for JBuilder to see it is just to create a library for servlet.jar and add it to the project.
    Tools->Configure Libraries->New
    Then browse to the location of the servlet.jar and call the library SERVLET.
    Project->Project Settings->Required Libraries
    Then add this library and try to build your project.
    JBuilder will automatically add it to the classpath when it compiles the project that way.

  • Javax.servlet package -- where is it?

    Downloaded latest version of Tomcat and expected the javax.servlet pacakge to be in the folders but it appears to not be. Where can I go to get the jar file for this?

    Did you download the lite version of Tomcat for JDK 1.4? I'm not sure what all that leaves out as I've never used it, I always go for the full package, but it's possible it doesn't include javax.servlet since it's part of JDK 1.4.

  • Where is the javax sound package for download?

    Where is the javax sound package for download? (URL) I got the latest JDK yesterday and tried to compile some audio applet but it looks like all of the Javax stuff is missing from the latest JDK.
    Where do I download the javax sound package ?
    Dan

    This is an audio player that another posted here. I tried to compile and run it but here were the results.
    javac SimplePlayerApplet.javaSimplePlayerApplet.java:9: package javax.media does not exist
    import javax.media.*;
    ^
    SimplePlayerApplet.java:11: cannot find symbol
    symbol: class ControllerListener
    public class SimplePlayerApplet extends Applet implements ControllerListener {
    ^
    SimplePlayerApplet.java:14: cannot find symbol
    symbol : class Player
    location: class SimplePlayerApplet
    Player player = null;
    ^
    SimplePlayerApplet.java:122: cannot find symbol
    symbol : class ControllerEvent
    location: class SimplePlayerApplet
    public synchronized void controllerUpdate(ControllerEvent event) {
    ^
    SimplePlayerApplet.java:44: cannot find symbol
    symbol : class MediaLocator
    location: class SimplePlayerApplet
              MediaLocator mrl = null;
              ^
    SimplePlayerApplet.java:63: cannot find symbol
    symbol : class MediaLocator
    location: class SimplePlayerApplet
              if ((mrl = new MediaLocator(mediaFile)) == null)
              ^
    SimplePlayerApplet.java:68: cannot find symbol
    symbol : variable Manager
    location: class SimplePlayerApplet
                        player = Manager.createPlayer(mrl);
                        ^
    SimplePlayerApplet.java:69: cannot find symbol
    symbol : class NoPlayerException
    location: class SimplePlayerApplet
              } catch (NoPlayerException e) {
              ^
    SimplePlayerApplet.java:130: cannot find symbol
    symbol : class RealizeCompleteEvent
    location: class SimplePlayerApplet
         if (event instanceof RealizeCompleteEvent) {
         ^
    SimplePlayerApplet.java:165: cannot find symbol
    symbol : class CachingControlEvent
    location: class SimplePlayerApplet
         } else if (event instanceof CachingControlEvent) {
         ^
    SimplePlayerApplet.java:166: cannot find symbol
    symbol : variable Controller
    location: class SimplePlayerApplet
         if (player.getState() > Controller.Realizing)
         ^
    SimplePlayerApplet.java:170: cannot find symbol
    symbol : class CachingControlEvent
    location: class SimplePlayerApplet
         CachingControlEvent e = (CachingControlEvent) event;
         ^
    SimplePlayerApplet.java:170: cannot find symbol
    symbol : class CachingControlEvent
    location: class SimplePlayerApplet
         CachingControlEvent e = (CachingControlEvent) event;
         ^
    SimplePlayerApplet.java:171: cannot find symbol
    symbol : class CachingControl
    location: class SimplePlayerApplet
         CachingControl cc = e.getCachingControl();
         ^
    SimplePlayerApplet.java:181: cannot find symbol
    symbol : class EndOfMediaEvent
    location: class SimplePlayerApplet
         } else if (event instanceof EndOfMediaEvent) {
         ^
    SimplePlayerApplet.java:184: cannot find symbol
    symbol : class Time
    location: class SimplePlayerApplet
         player.setMediaTime(new Time(0));
         ^
    SimplePlayerApplet.java:186: cannot find symbol
    symbol : class ControllerErrorEvent
    location: class SimplePlayerApplet
         } else if (event instanceof ControllerErrorEvent) {
         ^
    SimplePlayerApplet.java:189: cannot find symbol
    symbol : class ControllerErrorEvent
    location: class SimplePlayerApplet
         Fatal(((ControllerErrorEvent)event).getMessage());
         ^
    SimplePlayerApplet.java:190: cannot find symbol
    symbol : class ControllerClosedEvent
    location: class SimplePlayerApplet
    } else if (event instanceof ControllerClosedEvent) {
    ^
    19 errors
    So what am I missing ...and where do I get it ??
    Dan

  • How to get javax.servlet package

    Hi guys
    Does anybody know how to get javax.servlet package?
    Thanks in advance.
    Regards,
    Mark.

    I just moved the servlet jar into java_home/jre/lib/ext and I made some progress. Instead I recieved this error
    ---------- Javac ----------
    Note: C:\jdk1.3.1_04\bin\java\lang\ThreadGroup.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details.
    Normal Termination
    Output completed (17 sec consumed).
    DOes anyone have an idaea of what would cause this when it had compiled normally before?
    THanks Bruce

  • Missing classes from the javax.swing package?

    Can anyone throw any light on what appears to be a missing class from the javax.swing package?
    When CelsiusConverter.java from The Swing Tutorial (code fragment shown below) is compiled the JFrame class can't be found.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class CelsiusConverter implements ActionListener {
        JFrame converterFrame;Despite the package javax.swing being imported, the compiler does not seem to be be able to find the JFrame class.
    CelsiusConverter.java:14: Class JFrame not found in type declaration.
        JFrame converterFrame;To attempt to solve this issue all the files in jdk1.5.0_02\lib were added to CLASSPATH.
    CLASSPATH was set to C:\Program Files\Java\jdk1.5.0_02\lib\dt.jar;C:\Program Files\Java\jdk1.5.0_02\lib\htmlconverter.jar;C:\Program Files\Java\jdk1.5.0_02\lib\jconsole.jar;C:\Program Files\Java\jdk1.5.0_02\lib\tools.jar;C:\Program Files\Java\jdk1.5.0_02\lib;C:\Program Files\Java\jdk1.5.0_02\lib\ir.idl;C:\Program Files\Java\jdk1.5.0_02\lib\jawt.lib;C:\Program Files\Java\jdk1.5.0_02\lib\jvm.lib;C:\Program Files\Java\jdk1.5.0_02\lib\orb.idl;C:\Program Files\Java\jdk1.5.0_02\demo\jfc\SwingApplet\SwingApplet.jar;.;c:\CoreJavaBook

    This is extremely strange... If you're sure it's not a problem in your code or with your classpath, the only other thing I can think to suggest is re-downloading / installing java

  • I cannot find javax.servlet package in j2sdk-1.4.0-beta3

    I just download and install j2sdk-1.4.0-beta3 and progam a very simple program use import javax.servlet.* and compile it, there is a mistake:
    package javax.servlet.* does not exist
    And I check the doc of j2sdk-1.4.0-beta3,I also can not find package javax.servlet.So where could I find this package? Need I configure somewhere or download another products?

    Hi,
    You can go to http://java.sun.com/products/servlet/download.html,
    download the servlet 2.3 class files, add the zip file to the classpath.

  • Javax.servlet package does not exits

    Hi all
    i have set my classpath as follows:-
    J2EE_HOME - c:\Sun\Appserver
    path - %JAVA_HOME%\bin;%J2EE_HOME%\bin
    set classpath- .;%JAVA_HOME%\lib;%J2EE_HOME%\lib\j2ee.jar
    my j2se path and classpath already set
    but after setting path and classpath for j2ee i m not able to compile my servlet
    the error is package javax.servlet does not exits
    i know this error arised when we dont include j2ee.jar in classpath , but i m using j2ee.jar as well in my classpath
    plz suggest

    but you can also try including it in the web-inf\lib folder of your webapp.You should NEVER bundle the servlet-api.jar into the WEB-INF/lib folder of a web application.
    The server will always have its own copy. Putting your own there will just confuse things, and create errors.
    Ok, so you have set the classpath. What tool are you using to compile your code? Does it look at the classpath?
    Cheers,
    evnafets

Maybe you are looking for