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

Similar Messages

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

  • How can I import a servlet inside a JSP?

    Hi! I have seen tons of instructions on importing beans inside a JSP page but I want to use servlets instead. This question might be stupid, but I'm not really adept with JSPs yet and I hope you can help me.
    I need to import classes inside my JSP page so that I can use the methods and manipulate them through the JSP.
    Thank you!
    lauramos

    I'm curious, have you looked into using the MVC or Struts framework? One idea would be to map the Servlet you created to a JSP via XML (or any other mapping you want #?.jhtml for all that matters) and jsp:include as needed. Just a few mappings needed in WEB-INF/web.xml for instance...
    <servlet>
    ��<servlet-name>HeaderPageHandler</servlet-name>
    ��<servlet-class>packagename.HeaderPageHandler</servlet-class>
    </servlet>
    <servlet-mapping>
    ��<servlet-name>HeaderPageHandler</servlet-name>
    ��<url-pattern>/header_page.jsp</url-pattern>
    </servlet-mapping>
    In the JSP:
    <jsp:include page = "header_page.jsp" flush = "true" />
    The Servlet could forward the information over to another page using the getRequestDispatcher(String url).include(req, resp); From there, use the application or request scope to handle the jsp:useBean to output what you need. You could take that further and customize some of your own TLDs so you could state simple tags like <tag:output class="text">some text here</tag:output>

  • How to import javax.servlet.....

    I have a problem import javax.servlet.*.
    I need a class file, but "can't import javax.servlet.*",so jcreator told me
    package javax.servlet.* does not exist.
    using:
    jsdk 1.4.2
    compile tools:
    jcreator 2.5
    Hope someone tell me what to do??
    Thanks Advance!
    fiorear

    For JCreator, u also have to set it urself so it can be noticed when u complie servlets
    Go to Configure --> options --> select JDK profiles --> select the current version of jdk u r using --> click Edit tab --> add in the directory where u put in ur servlet.jar file
    Good luck.

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

  • 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

  • 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 can I import a  library ??

    How can use the WSDP library of inside Java SDK? I want to use the javax.servlet class but it is not available in SDK, however it is available in WSDP .How can I import them into Java1.4.1 Applications ?
    2nd:I have already set JAVA_HOME & ANT_HOME as permenant Environment Variables .the ant build command gives me a message that the setenv.bat is not recognized .
    The problem is that setenv.batch is in another directory of the ANT_HOME's and I don't know what variable I should use to point to it.

    What classes in particular are you wanting to use? If they're sitting there as jars on your box -- add them to your classpath when you compile/execute and all should be well.
    Some of these classes will most likely have dependencies upon classes associated with the J2EE platform (considering that a good deal of them are fashioned to execute inside of some form of servlet container) -- so, it's a wise idea to go ahead and grab the J2EE SDK as well.
    And, people do care, they just don't care for someone that nags.

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

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

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

  • 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! :)

  • Where can i find javax.servlet.http.httpServletRequest in weblogic jars

    Hi,
    i'm migrating from weblogic 8 to weblogic 10.3.
    in my java codes, i use import javax.servlet.http.httpServletRequest. Previously this package can in found in weblogic.jar in weblogic 8.
    However weblogic.jar for 10.3 does not have this package. Where can i find this package?
    Thanks

    oh i see. the api.jar has the indicate the path to the servlet package.
    /modules/javax.servlet_1.0.0.0-2-5.jar.
    Thanks for the guidance.:)

Maybe you are looking for

  • How to us iPhone backup file from Time Machine drive to restore iPhone

    Stupidly, I deleted my primary account on my iPhone that contained my contacts and calendar. I don't currently subscribe to MobileMe. I took advantage of the free service when I bought my phone, but decided not to subscribe as I synch my iPhone to my

  • How to get Numric value from a Char field in the database?

    I have the following values in a column in Database. COMP GRADE CANC CANCELLED Comp Complete INCOMP NC NS 85% 79 88 .... etc.... I have to take the value from this field if it is a Numeric other wise I have to ignore that value. Please let me know ho

  • HP Solutions Center doesn't work for my C7280

    I have a C7280 All In One and just got a new PC running Windows 7 (32 bit). Now when I try to run the Solutions Center to scan a picture it says that I don't have the SW installed so I went to the site and downloaded the entire SW suite for my printe

  • Upgrading Oracle Apps Server from 10g (10.1.3.0) to 10.1.3.5

    Have the following question. First time upgrading Oracle Apps Server. So not that familiar in this area. 1. Step 6.1.2 in Oracle Application Server Patch Set Notes it says <p> If you are applying 10g Release 3 (10.1.3) Patch Set 5 (10.1.3.5.0) to a 1

  • Intermittent wifi signal loss

    I have a HTC mobile with the BTWIFI app. When conected  to a WIFI hotspot i frequently loose the signal and then approx 30 seconds later reconnect again, i find that this happens when indoors. The app states that i am connected to BTWIFI however i do