Cannot import javax.servlet

Hello,
I'm trying to write a javabean to use with in jsp code.
In the bean I need to use <code>HttpServletResponse and for this I need to add :
</code>import javax.servlet.*;
import javax.servlet.http.*;
this throws me the exception : package javax.servlet does not exist.
CLASSPATH = .;D:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar;D:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\jsp-api.jar;D:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\el-api.jar;
I have no idea where I need to include this class.
Thanks in advance for your help.

No idea about Netbeans, but in Eclipse you can just accosiate an application server with the web project, then it will automatically take its libraries (the javax.servlet and so on) in the buildpath.

Similar Messages

  • Cannot Import javax.servlet.* and javax.servlet.http.*

    Hello,
    I am a University Student and now doing a project using Servlet and JSP
    I have installed WinXP and Tomcat 5.0 on my computer
    When I compile the servlet , there are error messages "package javax.servlet does not exist" and "package javax.servlet.http does not exist" coming out.
    I have set the classpath already
    i.e. %CATALINA_HOME%\common\lib\servlet-api.jar;%CATALINA_HOME%\common\lib\jsp-api.jar
    ( Of course "%CATALINA_HOME%" = my folder that install the Tomcat )
    Can Anybody Explain what is happening and suggest a solution to me?
    Please give a hand.

    When you ran that command, what happened? Let javac.exe tell you the right answer.
    I'd advise two things:
    (1) Installing any s'ware in a directory whose name contains spaces (e.g., "Apache Software Foundation" or "Tomcat 5.0") is a very bad idea, IMO. I'd reinstall to a new directory.
    (2) Your HelloServlet.java servlet probably doesn't have a package statement in it. Tomcat 5.0 won't play nicely with servlets or beans that aren't in packages. I'd add one and use the -d . option on javac.exe to make sure it created the package directory structure for me.

  • Cannot import javax.servlet onto classpath

    Hi guys, newbie question.
    Im using jedit on linux; compiling with j2sdk1.4.2_04 but it will not pick up the javax.serlet
    classes!! Is there an add on I need to download to develop j2ee stuff, as I thought j2sdk1.4.2_04 was all that was required.
    Thanks in advance

    Wrong. You need a JAR that has the javax.servlet and javax.servlet.http packages, and they don't come with the J2SE.
    If you want to run servlets/JSPs, you must have a servlet/JSP engine. If you already have one, root around for the servlet JAR. If don't, download Tomcat. It's Sun's reference implementation for the servlet/JSP specifications. The servlet JAR will be in the TOMCAT_HOME/common/lib directory.

  • Getting an error like this The import javax.servlet cannot be resolved

    HI
    i am getting an error like this "The import javax.servlet cannot be resolved".wht i ahve done in eclipse right click->open->servlet->packge name->servlet name->next->nexyt>finish.hereinterfaces is javax.servlet.Servlet.
    do i need add jar for it.can any one tell me why i got error like this.
    vijay

    Please don't doublepost. Answer is given here: http://forum.java.sun.com/thread.jspa?threadID=5220686

  • Having problems compiling *.java with import javax.servlet.jsp......

    I've been trying to do the tutorials in a book titled Apache Jakarta-Tomcat as part of my introduction to JSP. I'm new to Java but do know the basics. I have on my machine Java 1.3, Java 1.4, Java FrameWorks 2.1 and Jython 2.1 on Win2000 Pro. So enough about my configuration. I have never worked with packages also.
    I downloaded the files from the books site due to the fact I make a lot of typos when hand coding Java (I've become a pretty good debugger of my own code). But everytime I go to compile the *.java I get error messages. So below you will find HelloTag.java and beneath that the error messages that are thrown when I try and compile it. I tested other bits of *.java and have had no problem compiling them. Is there a JSP module I'm missing?
    Am I doing something wrong or am I missing something from my configuration.
    Marijan Madunic
    package chapter2;
    import javax.servlet.jsp.JspException;
    import javax.servlet.jsp.JspTagException;
    import javax.servlet.jsp.tagext.TagSupport;
    public class HelloTag extends TagSupport
    public void HelloTag() {
    // Method called when the closing hello tag is encountered
    public int doEndTag() throws JspException {
    try {
    // We use the pageContext to get a Writer
    // We then print the text string Hello
    pageContext.getOut().print("Hello");
    catch (Exception e) {
    throw new JspTagException(e.getMessage());
    // We want to return SKIP_BODY because this Tag does not support
    // a Tag Body
    return SKIP_BODY;
    public void release() {
    // Call the parent's release to release any resources
    // used by the parent tag.
    // This is just good practice for when you start creating
    // hierarchies of tags.
    super.release();
    D:\Java\JDK 1.3\bin>javac HelloTag.java
    HelloTag.java:3: cannot resolve symbol
    symbol : class JspException
    location: package jsp
    import javax.servlet.jsp.JspException;
    ^
    HelloTag.java:4: cannot resolve symbol
    symbol : class JspTagException
    location: package jsp
    import javax.servlet.jsp.JspTagException;
    ^
    HelloTag.java:5: cannot resolve symbol
    symbol : class TagSupport
    location: package tagext
    import javax.servlet.jsp.tagext.TagSupport;
    ^
    HelloTag.java:7: cannot resolve symbol
    symbol : class TagSupport
    location: class chapter2.HelloTag
    public class HelloTag extends TagSupport
    ^
    HelloTag.java:14: cannot resolve symbol
    symbol : class JspException
    location: class chapter2.HelloTag
    public int doEndTag() throws JspException {
    ^
    HelloTag.java:20: cannot resolve symbol
    symbol : variable pageContext
    location: class chapter2.HelloTag
    pageContext.getOut().print("Hello");
    ^
    HelloTag.java:24: cannot resolve symbol
    symbol : class JspTagException
    location: class chapter2.HelloTag
    throw new JspTagException(e.getMessage());
    ^
    HelloTag.java:28: cannot resolve symbol
    symbol : variable SKIP_BODY
    location: class chapter2.HelloTag
    return SKIP_BODY;
    ^
    HelloTag.java:37: cannot resolve symbol
    symbol : variable super
    location: class chapter2.HelloTag
    super.release();
    ^
    9 errors

    Well, it looks like you've not got the servlet development kit JAR on your classpath. I think it'll probably be called servlet.jar on your system. Add that to the classpath if it's not already there.
    Incidentally, you've bumped into one of the areas Java's slightly lenient - declaring a method that looks like a constructor:
    public HelloTag() { }
    public void HelloTag() { }The first is a constructor, the second is a normal method. I'm assuming you intended to have the former instead of the latter.
    Anyway, hope this helps.

  • 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

  • Error on import javax.servlet.*;

    Hi everyone,
    I am trying to compile a servlet and i receive this errors:
    C:\HAMID\JAVA>javac Welcome.java
    Welcome.java:7: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    Welcome.java:8: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    Welcome.java:10: cannot resolve symbol
    symbol : class HttpServlet
    location: class Welcome
    public class Welcome extends HttpServlet {
    ^
    Welcome.java:12: cannot resolve symbol
    symbol : class HttpServletRequest
    location: class Welcome
    public void doGet(HttpServletRequest request,
    ^
    Welcome.java:13: cannot resolve symbol
    symbol : class HttpServletResponse
    location: class Welcome
    HttpServletResponse response)
    ^
    Welcome.java:14: cannot resolve symbol
    symbol : class ServletException
    location: class Welcome
    throws ServletException, IOException {
    ^
    6 errors
    C:\HAMID\JAVA>
    Could you please let me know what to do?
    thanks
    Hamid

    servlet.jar is not in your classpath. You should not get this error once you include this in your classpath.

  • Cannot find javax.servlet in J2EE

    I am learning about servlet programming. I am using JBuilder-student edition. I downloaded J2EE. I changed the project properties in JBuilder to use the java.exe in J2EE, but when I try importing javax.servlet or the like, it does not show that javax has such a package. Please help. I am working on this project with a professor, and I have to show some work done soon! I cannot get started with my work unless I get javax.servlet.
    I hope somebody can help me.
    Thank you,

    It seemed that the installation did not unzip the j2ee.WAR, which contains the servlet stuff.(or is it not supposed to?) I then added the folder j2ee to the class path, and it works. I am dumb enough not to understand how it worked, could someone explain please.
    Thank you

  • How can I import javax.servlet.*?

    I am having the following problem:
    [ppandit@localhost projects]$ javac HelloServlet.java
    HelloServlet.java:2: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    HelloServlet.java:4: cannot resolve symbol
    symbol : class GenericServlet
    location: class HelloServlet
    I am taking a JSP class and starting to get my development environment set up.
    I have JDK 1.4 installed as well as J2EE 1.3.1
    What could be my problem?
    Par

    I was able to contact my instructor. He told me to add the tomcat4/common/lub/servlets.jar file to my classpath. This was symbollically linked to another file.
    /var/tomcat4/common/lib/servlets.jar -> /usr/share/java/servlet-2.3.jar
    /usr/share/java/servlet-2.3.jar -> /usr/share/java/servlet-2.3-4.0.3.jar
    This worked.
    Thanks for your help. I am sure I will have more questions as I progress in this class.
    Par

  • Custom Class file errors out on import javax.servlet.http.HttpSession

    I am trying to write a class file to handle events. This is a test class file copied from the UIX Docs. When I put this in JDeveloper 903 ,and build it the compiler gives the error:
    Error(2,27): cannot access class javax.servlet.http.HttpSession; file javax\servlet\http\HttpSession.class not found
    I am not sure what is the problem? Can anyone please help?
    Here is the code:--
    package mypackage1;
    import javax.servlet.http.HttpSession;
    import oracle.cabo.servlet.Page;
    import oracle.cabo.servlet.BajaContext;
    import oracle.cabo.servlet.event.PageEvent;
    import oracle.cabo.servlet.event.EventResult;
    public class MyClass
    /** This is handleStoreNameEvent version 1 */
    public static EventResult handleStoreNameEvent(BajaContext context,
    Page page,
    PageEvent event)
    String userName = event.getParameter("txt1");
    HttpSession session = context.getServletRequest().getSession(true);
    session.putValue("User Name", userName);
    Page nextPage = new Page("NextPage");
    return new EventResult(nextPage);
    }

    Hi, you are missing the servlet.jar file from your classpath.
    In JDeveloper, you can add this by opening up your project -> libraries and adding the servlet runtime library.

  • How to import javax.servlet.http.*

    Dear all,
    I'm trying to create an applet that writes (and later reads) a cookie from the clients local HDD. The first thing I run into is that I'm unable to import the nessecary class, which would be, I think, "javax.servlet.http.cookie". I'm using JBuilder 8.0 and every time I'm typing "import javax.servlet"
    I get the message "cannot acces the directory "javax.servlet".
    How should I troubleshoot this problem?
    Regards Ronald

    Dear Myself,
    I solved the trouble. What I have done is I downloaded the enterprise 1.4 SDK and added the j2ee.jar to the JBuilder 8.0 JDK directories.
    Problem solved.
    Yippie....
    Bye.

  • Import javax.servlet.jsp.*;

    I am new to JSP.I getting errors in compilation.Can anyone please tell me the following import file can be found in which development kit.
    "import javax.servlet.jsp.*;

    You can download J2EE from sun's website. What you need is servlet.jar package. Put it in your CLASSPATH.

  • Import javax.servlet.* package not found

    hai i am pradeep i am using java 1.5 and tomcat 5.5 version when i just include import javax.servlet.* in simple hellow word program and compile it shows error
    import javax.servlet.* package not found
    i set my class path to as
    E:\set path="D:\Program Files\Java\jdk1.5.0_04\bin" and compile this it pops a message please help me i am using winxp os
    by
    pradeep sreedharan

    you are not setting the classpath but the path, and they should both be written in capitals, PATH and CLASSPATH.
    The classpath contains directories and jar files that contain the classes that need to be "visible" to your applications. The servlet classes are part of the file servlet-api.jar, which you can find in your tomcat directory, more specifically the common/lib sub directory.
    I would expect your classpath to look something like this:
    .;d:\program files\tomcat\common\lib\servlet-api.jar
    You may also want to add the directory in which you are storing your projects, I don't know how you are building your applications.
    You seem to be very new to this, so I would suggest you give this a read:
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html

  • Import javax.servlet.* gives error "package does not exist"

    I am working through Monica Pawlan's book "Essentials of Java PL".
    My PC runs Windows2000 prof. I have downloaded and installed j2sdk-1_3_1_01-win.exe in c:\jdk1.3.1_01
    I have downloaded and installed tomcat4.0 (jakarta-tomcat-4.0.zip) into c:\jakarta-tomcat-4.0
    CATALINA_HOME is set to c:\jakarta-tomcat-4.0 and CLASSPATH is set to .;C:\jakarta-tomcat-4.0\common\lib\servlet.jar
    I can compile an applet starting:
    import java.awt.Color;
    import java.awt.BorderLayout;
    import java.awt.event.*;
    import javax.swing.*;
    //Class Declaration
    class SwingUI extends JFrame implements ActionListener { ... }
    but trying to compile my servlet starting:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ExampServlet extends HttpServlet { ... }
    gives me the error (import javax.servlet.*) "package does not exist".
    Any pointers on this immediate problem? and is my book out of date?
    Many thanks,
    James Towell

    You downloaded the Java 2 SDK Standard Edition, but you need to also download the Enterprise Edition if you want to write programs that use enterprise features.

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

Maybe you are looking for

  • Itunes won't open. says error report

    everytime i click on itunes a window comes up saying "iTunes has encountered a problem and needs to close. we are sorry for the inconvenience." then at the buttom there are two links sayind SEND ERROR REPORT and DON'T SEND. clicking either one won't

  • How can I find out the name of an artist in the download library?

    Yesterday my friend configured his iPod nano. At the end of the setup, a library of some 30 songs was downloaded to his iPod. He told me he loved one of the songs called Sons and Daughters, but the album/artist displayed as Anonymous. It's a moving a

  • How  can create SEGMENTS and IDOC TYPE in BADI in ECC 6.0 version

    Hi All,             Can any one help, how  to create SEGMENTS and IDOC TYPE in BADI in ECC 6.0 version.This is my task. Given BADI name was----VENDOR_ADD_DATA_BI . Thanks

  • LMS 3.2 SP1 RME showing no records in syslog report while same report in device center shows

    Hi All, I have LMS 3.2  SP1 running on windows machine, when i am generating 24 hours report(Standard) in RME i do not see any records, while in Device center  in Device Diagnostic center, i can see the same report showing the logs.  i have checked t

  • Validity period on e-mail addresses

    Hello, I have several e-mail address entries on an account, even though the e-mail address is the same. It seems like the system creates new entries when I change the flags "Standard" and "Do not use". I think it is rather confusing to display all en