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.

Similar Messages

  • Error in importing javax.servlet.ServletConfig;

    Hi
    I am fairly new to servlets technology
    while importing package javax.servlet.ServletConfig; i got error Create class "ServletConfig" in package javax.servlet
    I'm using eclipse IDE

    Which project have you created in eclipse?
    Java or J2EE project?
    If its a J2EE project, the jars will be included automatically in the lib
    but if its a Java project, you will have to include the servlet-api.jar in the classpath.

  • 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

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

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

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

  • 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

  • How solve  import javax.servlet.http.HttpServlet err import javax.servlet.

    Hi
    I am trying to compile one servlet code using commancd prompt and i get
    package javax.servlet.http does not exist import javax.servlet.http.HttpServlet;
    error for following code
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    public class SampleServlet extends HttpServlet
    public void saveToSession(HttpServletRequest request)
         String testparam = request.getParameter("testparam");
         request.getSession().setAttribute("testAttribute", testparam);
    please help me

    Try giving servlet..jar path in the class path variable

  • Erorr " import javax.servlet.*"

    For every one!
    I use JDK1.4.0 to develope in Java . But when i study come to Servlet and when i import the library :
    "-----import javax.servlet.*---------"
    to explore the erorr that can't open this package. Now i don't know to answer this question.
    Can any one help me with this?
    Outside , these are some erorr for this , when i import this Package : Javax.servlet.*, ....
    Thanks for read my post.

    Here a direct answer to your question, cutting all the bullcraps that's meaningless to you, which other people told you on the forums you been looking at including this one:
    1. install j2ee, I think everyone is clear on that.
    2. there should be a page pop up after you finish the installation, and on top it says "Congratulations - You've Completed Installation!"
    3. If you don't see this page or you closed it b4 you realize you have a problem on the classpath, go to your j2ee folder and look under doc folder, it will be under the name (((((((about.html/htm))))))) whichever it is.
    4. Then look down about 20 lines including empty lines, there should be a link that says:
    "Your First Cup: An Introduction to the Java EE Platform: Provides detailed instructions for compiling and running your first program."
    If some varies from the instruction than your machine:
    1. make sure your system is compatiable with the version of java you installed, it will not run on some of the OS including some version of Windows last time i checked. XP and Vista should be okay i believe.
    2. recheck and make sure you done everything correctly.
    3. contact java support if there's one if you still think something is worng.
    (That's assuming you have no error messages while installing the program, if you not sure about that, reinstall it and note it carefully)
    And finally if you are too lazy to look through this instruction or still too dumb to figure this out:
    1. uninstall your j2ee.
    2. quit your job/school study/hobby as a programmer.
    3. choose a new job/school study/hobby.
    Took me 2 hours to figure this out while i'm watching youtube so shouldn't be hard once you find this step by step instruction.
    And also there's a lot of other goodies such as: Setting up a tomcat server, which got NOTHING to do with coding a java servlet page, it's a server you host the page on.
    And please read carefully on other people's comment before you reply so the person who wrote the original message won't be like "WTH is this guy talking about??$*@&!?"
    Good luck too you! :)

  • Can't import javax.servlet.*

    I have installed the jdk 1.3.1 standard edition. I downloaded this from the sun web site. I can import javax.swing ... but get an error when trying to import javax.servlet.*; The error I get says 'package javax.servlet does not exist'.
    Where do I get the package?
    How can I check to see if I have the package?
    Thank You

    That's because javax.servlet is not part of Java 2 SDK SE. It's part of Java 2 SDK EE -- you need to download and install the Enterprise Edition in addition to the Standard Edition.

  • Import.javax.servlet.*;

    I receive error message package.javax.servlet does not exist. Is there something that I need to do to fix this?

    http://developer.java.sun.com/developer/earlyAccess/j2sdkee/
    http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.18/bin/

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

  • 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

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

Maybe you are looking for