Servlet package not found error

I am getting the following error while running my servlet .I have servlet.jar,servlet-api.jar,servlet-2_5-api in my lib directory.Do i have to give path for .jar files??
C:\j2sdk1.4.2_02\bin>javac PostParameterServlet.java
PostParameterServlet.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
PostParameterServlet.java:6: cannot resolve symbol
symbol  : class GenericServlet
location: class PostParameterServlet
class  PostParameterServlet extends GenericServlet
                                    ^
PostParameterServlet.java:8: cannot resolve symbol
symbol  : class ServletRequest
location: class PostParameterServlet
        public void service(ServletRequest req,ServletResponse res)throws ServletException,
IOException
                            ^
PostParameterServlet.java:8: cannot resolve symbol
symbol  : class ServletResponse
location: class PostParameterServlet
        public void service(ServletRequest req,ServletResponse res)throws ServletException,
IOException
                                               ^
PostParameterServlet.java:8: cannot resolve symbol
symbol  : class ServletException
location: class PostParameterServlet
        public void service(ServletRequest req,ServletResponse res)throws ServletException,
IOException
                                                                          ^
5 errorsand here my code
import java.io.*;
import java.util.*;
import javax.servlet.*;
class  PostParameterServlet extends GenericServlet
     public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException
          PrintWriter pw=res.getWriter();
          Enumeration e=req.getParameterNames();
          while(e.hasMoreElements())
               String pname=(String)e.nextElement();
               pw.print(pname +"=");
               String pvalue=req.getParameter(pname);
               pw.println(pvalue);
          pw.close();
}

Sun_Rockz wrote:
C:\Suraj\jspproj\beerV1>javac -classpath "c:\apache software foundation\tomcat 5
.5\common\lib\servlet-api.jar;classes" -d classes src\com\example\web\beerselect
.javaYou've quoted the classpath the wrong way. Only quote the separate paths, not all paths together, it would be seen as a single path otherwise.

Similar Messages

  • Servlet package not found

    I am trying to compile a servlet and i keep getting the error 'servlet package not found' I went and downloaded the servlet package but am unsure how to implement. I assume the i would need to ammend the classpath or path, but not sure. If someone could give some simple instructions, I'd be grateful.

    hi,
    as mentioned you will have to add the servlet package to the classpath environment variable.
    lez say the java servlet class files are present in the servlet.jar file.. herez how u would add it to the classpath ..
    set CLASSPATH=%CLASSPATH%;<path-to-jar>\servlet.jar;.
    Therez a dot at the end of the classpath (this puts the current directory in the CLASSPATH)
    you would have to replace the <path-to-jar> with the actual location for eg
    set CLASSPATH=%CLASSPATH%;c:\java\servlets\lib\servlet.jar;.
    hope this helpz
    cheerz
    ynkrish

  • Servlet class not found error deploying a WAR on Web Logic Server 8.1

    I'm re-deploying an updated web application to a web logic server, but when I navigate to the login page of the web application to test it, I get a class not found error for my login servlet. I have both the web.xml and the weblogic.xml descriptors in my WEB-INF directory, and all of my compiled classes are in the WEB-INF/classes directory, is there something else I'm missing? Any help would be much appreciated.

    Thanks for the response. Here's the web.xml file:
    <?xml version="1.0" ?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
         <display-name>Web Forms</display-name>
    <servlet>
    <servlet-name>LoginServlet</servlet-name>
    <display-name>LoginServlet</display-name>
    <servlet-class>LoginServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>ChangePasswordServlet</servlet-name>
    <display-name>ChangePasswordServlet</display-name>
    <servlet-class>ChangePasswordServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>LogoutServlet</servlet-name>
    <display-name>LogoutServlet</display-name>
    <servlet-class>LogoutServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>PageServlet</servlet-name>
    <display-name>PageServlet</display-name>
    <servlet-class>PageServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>UploadServlet</servlet-name>
    <display-name>UploadServlet</display-name>
    <servlet-class>UploadServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/LoginServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>ChangePasswordServlet</servlet-name>
    <url-pattern>/ChangePasswordServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>LogoutServlet</servlet-name>
    <url-pattern>/LogoutServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>UploadServlet</servlet-name>
    <url-pattern>/UploadServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>PageServlet</servlet-name>
    <url-pattern>/PageServlet</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
    <welcome-file>Login.jsp</welcome-file>
    </welcome-file-list>
    </web-app>
    None of the classes are in a package (I know it's not the best idea, but I didn't write these, I'm just doing some updates). So the file structure is pretty much just WEB-INF/classes/
    At the moment I've got a fix by just putting the entire project (not in any sort of archive) on the server itself instead of deploying it as a WAR, any thoughts on why the WAR isn't working would be much appreciated though.

  • Package not found error...please help!!!!

    I am trying build an application using Apache Http server and tomcat. I have created a package called 'employee' under web-inf/classes. I have also put my servlet under web-inf/classes. In my servlet if I use the statement 'import emplyee.*' it gives me a compilation error - 'package employee not found. I was trying to compile the servlet from the DOS prompt web-inf/classes>. I have set my classpath to include lib/j2ee.jar and web-ibf/classes. What am I doing wrong?

    Try setting classpath as web-ibf/classes/employee.jar. Create a jar consisting of the employee package's
    classes.
    Hope this helps.
    Thanks,
    Chandra Mohan

  • Javax.servlet.* Not Found Error - Please help

    I am having a great deal deal of trouble trying to compile a program using javax.servlet and javax.servlet.hhtp.*. I have setup the JAVA_HOME and the CLASSPATH variables as per the Installation instructions. I appear to have hit a brick wall and I am absolutely desperate to get this working. I have installed the J2EE SDK as well as the Servletapi2.1. Please Help.
    Variables:
    CLASSPATH=c:\jdk1.3\lib\tools.jar;c:\j2sdkee1.3.1\lib\j2ee.jar;c:\jdk1.3\jre\bin;c:\jdk1.3\jre\lib;c:\mm.mysql-2.0.14\org;c:\jdk1.3\lib\servlet.jar;
    JAVA_HOME=c:\jdk1.3;
    J2EE_HOME=c:\j2sdkee1.3.1;
    PATH=%PATH%;c:\jdk1.3\bin;c:\j2sdkee1.3.1\bin;
    Error message from compiler:
    L:\PROGRA~1\allaire\jrun\servers\default\loanstest\web-inf\classes\PasswordServlet.java:27: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    L:\PROGRA~1\allaire\jrun\servers\default\loanstest\web-inf\classes\PasswordServlet.java:30: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    L:\PROGRA~1\allaire\jrun\servers\default\loanstest\web-inf\classes\PasswordServlet.java:39: cannot resolve symbol
    symbol : class HttpServlet
    location: class PasswordServlet
    public class PasswordServlet extends HttpServlet

    I can only think of three suggestions.
    One, use your mouse to "cut-n-paste" the value of CLASSPATH and verify that those files are exactly where you think they are, and are spelled right.
    E.g.
    CD C:\JDK1.3\LIB
    DIR SERVLET.JAR
    Two, if they're spelled right, run "jar tvf" on the files to make sure they aren't corrupted or something.
    E.g.:
    JAR TVF SERVLET.JAR
    Three, since you're working in Windoze, try putting the value inside double quotes. E.g.:
    SET CLASSPATH="c:\jdk1.3\lib\tools.jar;c:\j2sdkee1 ... etc ... "
    If you haven't tried the above, give it a go, see what happens.

  • Intermedia - ORDWEBUTL package NOT found Error.

    Hi,
    The intermdeia Clipboard gives the following error message :
    The ORDWEBUTL package was not found in the requested database. Please contact your database administrator.
    How do I install this package in the database ?
    My OS : Windows 2000 Pro.
    Web server : iPlanet Web Server, Enterprise Edition 4.1
    Database :
    Oracle8i Enterprise Edition Release 8.1.6.0.0 - Production
    With the Partitioning option - JServer Release 8.1.6.0.0 Production.
    The webagent and Clipboard installation seems to be fine.
    Do we need OAS on the server side to run the example that uses interMedia to load and play MP3 from Oracle8i ?
    Thanks,
    Nathan
    null

    You can find the ordwebutl.sql script in your <ORACLE_HOME>od\web\admin.
    You can use the Web server of your choice, and it can reside on any machines. When you set up the Web Agent, just provide the appropriate information about the database you are connecting.

  • Pgrep Package Not Found Error

    Whenever someone logs onto this workstation, I get the following error:
    -bash: pgrep: command not found
    I did a search on these forums, Google, & Pacman. I couldn't find anything or packages for pgrep.

    $ pacman -Qo pgrep
    /usr/bin/pgrep is owned by procps 3.2.8-4
    It is in the base group so you are expected to have it installed.

  • Package not found error

    I am using net beans 6.7.1. I entered the following code:
    package javaapplication2;
    import java.security.Key;
    import java.security.KeyPair;
    import java.security.KeyPairGenerator;
    import java.security.SecureRandom;
    import java.security.Security;
    import javax.crypto.Cipher;
    class main{
      public static void main(String[] args) throws Exception {
        *Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());*
        byte[] input = "hi dinesh".getBytes();
        Cipher cipher = Cipher.getInstance("RSA/None/NoPadding", "BC");
        SecureRandom random = new SecureRandom();
        KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", "BC");
        generator.initialize(512, random);
        KeyPair pair = generator.generateKeyPair();
        Key pubKey = pair.getPublic();
        Key privKey = pair.getPrivate();
    //     System.out.println(privKey);
        cipher.init(Cipher.ENCRYPT_MODE, pubKey, random);
        byte[] cipherText = cipher.doFinal(input);
        System.out.println("cipher: " + new String(cipherText));
        cipher.init(Cipher.DECRYPT_MODE, privKey);
        byte[] plainText = cipher.doFinal(cipherText);
        System.out.println("plain : " + new String(plainText));
    }But it shows the error "package org.bouncycastle.jce.provider does not exist". What might be the error?
    When i run the same code in jdk1.6, i can get the output. i even added "bouncycastle" package. Somebody please help me. Thanks in advance

    sowndar wrote:
    But it shows the error "package org.bouncycastle.jce.provider does not exist". What might be the error?Exactly what it says. Netbeans doesn't know what that package is.
    When i run the same code in jdk1.6, i can get the output. i even added "bouncycastle" package.So you have the correct jar file but Netbeans cannot read your mind. You have to tell it where that jar file is. Therefore you have a Netbeans problem and not a Java one. Try asking in a Netbeans forum how to add third party libs into your project.

  • Package not found error in JDK 1.4

    I have been using JDk 1.2.2 quite well for more than 6 months for a client side GUI application. All my classes are in packages (com.aaa.gui.main, etc). However, on installing JDK 1.4 and trying to compile all the classes, i ran into an error. The javac compiler exited with this error "package com.aaa.gui.iges3d does not exist, import com.aaa.gui.iges3d.*).
    As mentioned earlier, the com.aaa.gui.iges3d is a package, so are the others. My classpath is "E:\es2.0". I would be thankful for any solution coming my way.
    Thanks
    Raghav

    I tried all options for classpath but was not successful. I then tried to compile all Java files by giving the command as "javac -classpath E:\es2.0; com\aaa\modeldb\*.java com\aaa\gui\iges3d\*.java etc" and it compiled all the classes.
    I dont know what is the error, but it is not compiling unless all the java source files are tried to compile.
    Raghav

  • Classpath set BUT still javax.servlet package not found when compiling

    Hello,
    I'm trying to compile a servlet and use tomcat 5 to run it. After I set the classpath to include the servlet-api.jar file, the compiler still tells me it cannot find package. I'm not sure what else to do. Please Help.
    Thanks Smoker

    Then you haven't set the actual classpath that the compiler is using. Just because you say you have set the 'classpath' doesn't mean you've properly told the compiler that.
    Such as, what did you do, set the CLASSPATH environment variable? Don't do that - ever. If that's what you did, and you're using an IDE, the IDE project is ignoring that environment variable anyway. You have to configure the project appropriately (which for one thing sets up the 'classpath' it uses), which varies depending on the IDE. That's an IDE question though, not a Java one.

  • Problems with Sun One Web Server 6.1 javax.xml.xpath package not found

    I used myeclipse to build an xml app and tested on jboss. it worked perfectly. However when i deployed it to our solaris sun one web server the app fell apart completely with the following error. I m unable to figure out what went wrong. Any help will be much appreciated.
    Thanks.
    [11/Dec/2007:22:12:37] failure (13539):      for host 121.247.233.169 trying to GET /feeds/rss.jsp, service-j2ee reports: StandardWrapperValve[jsp]: WEB2792: Servlet.service() for servlet jsp threw exception
         org.apache.jasper.JasperException: WEB4000: Unable to compile class for JSP
         /opt/SUNWwbsvr/test/ClassCache/test/_jsps/_feeds/_rss_jsp.java:8: package javax.xml.xpath does not exist
         import javax.xml.xpath.*;
         ^

    Thanks for the response. I tried to use xalan package which resolved the javax.xml.xpath package not found error (xalan.jar in WEB-INF/lib folder). However I m now getting the following error. Probably incompatible version is the reason. Please advise!
    [11/Dec/2007:23:46:28] failure (17028):      for host 121.247.233.169 trying to GET /feeds/rss.jsp, service-j2ee reports: StandardWrapperValve[jsp]: WEB2792: Servlet.service() for servlet jsp threw exception
         javax.servlet.ServletException: org.apache.xpath.XPathContext.<init>(Z)V
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
         at _jsps._feeds._rss_jsp._jspService(_rss_new_jsp.java:627)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
         at com.iplanet.ias.web.jsp.JspServlet$JspServletWrapper.service(JspServlet.java:687)
         at com.iplanet.ias.web.jsp.JspServlet.serviceJspFile(JspServlet.java:459)
         at com.iplanet.ias.web.jsp.JspServlet.service(JspServlet.java:375)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
         at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
         at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)
         ----- Root Cause -----
         java.lang.NoSuchMethodError: org.apache.xpath.XPathContext.<init>(Z)V
         at org.apache.xpath.jaxp.XPathImpl.eval(XPathImpl.java:207)
         at org.apache.xpath.jaxp.XPathImpl.evaluate(XPathImpl.java:281)
         at _jsps._feeds._rss_new_jsp._jspService(_rss_jsp.java:165)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
         at com.iplanet.ias.web.jsp.JspServlet$JspServletWrapper.service(JspServlet.java:687)
         at com.iplanet.ias.web.jsp.JspServlet.serviceJspFile(JspServlet.java:459)
         at com.iplanet.ias.web.jsp.JspServlet.service(JspServlet.java:375)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
         at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
         at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)

  • Java Servlet page not opening error 404

    Hi!
    I am working with servlets. I compiled the java file and the class file is been moved to
    c:\javawebserver2.0\servlets, and the html files moved to public_html. Html files r opening
    the classpath is mapped to jsdk.jar i.e
    set CLASSPATH=c:\javawebserver2.0\lib\jsdk.jar
    Built-in samples r working without any problem
    when i try to run the servlet
    Page Not Found error 404 occuring
    Please do the favour for me
    thanks

    404 Not Found means you didn't deploy the app properly.
    I think deploying an app like this is a terrible idea. If you have more than one app deployed on a production web server/servlet engine, you wouldn't want to put them all in the same place. "public_html" and the generic "servlets" directory shouldn't be used as dumping grounds for all your apps.
    Learn how to deploy using a WAR file. It'll keep all your apps separate and their constitutive parts together.
    Why Java Web Server? I don't think anyone uses it seriously anymore. Tomcat is the reference implementation of the servlet/JSP specs. I'd download that and use it instead of JWS. JMO, of course.

  • Package javax.servlet not found error

    package javax.servlet not found error. how it can be solved.
    plz help this is my first servlet program.
    vipin

    You need a jar file that has in it the javax.servlet.* classes
    It should be distributed with your servlet/jsp server.
    It can normally be found in a /lib directory under the installation.
    Some examples:
    Tomcat4: install_dir\common\lib\servlet.jar
    Tomcat5: install_dir\common\lib\servlet-api.jar; install_dir\common\lib\jsp-api.jar
    J2sdkee: install_dir/lib/j2ee.jar
    You need to include this jar file in your classpath when you compile any servlet.

  • 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

  • Getting 104 resource not found error, when deploying my first servlet

    Hi,
    I am new to servlets, and after doing little home work i have created a small servlet but i am i getting http 104 resource not found error.
    steps i followed:
    1) installed pre-configured version of tomcat from http://www.coreservlets.com/Apache-Tomcat-Tutorial/.
    2)created new directory called ch1 under webapps, created WEB-INF under ch1
    3)included web.xml, classes in WEB-INF directly
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
    version="2.5">
    <servlet>
    <servlet-name>Ch1servlet</servlet-name>
    <servlet-class>Ch1servlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Ch1servlet</servlet-name>
    <url-pattern>/servlet</url-pattern>
    </servlet-mapping>
    </web-app>
    4) included .class file under classes folder from following Ch1servlet.java file, I have set class path to point to servlet-api.jar file and jsp-api.jar and compliled following java file to get .class file which is included in classes folder
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class Ch1servlet extends HttpServlet
    public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException
    response.setContentType("text/html");
    PrintWriter out=response.getWriter();
    java.util.Date today=new java.util.Date();
    out.println("<html>"+
    "<body>"+
    "<h1 align=center>HF\'s Chapter1 Servlet</h1>"
    +"<br>" + today + "</body>" + "</html>");
    5) I am started tomcat server and when typed http://localhost( changed port from 8080 to 80), its giving tomcat page and not showing any error
    6) When i typed http://localhost/ch1/servlet/Ch1servlet, its giving http 404 error
    type Status report
    message: /servlet/Ch1servlet
    description: The requested resource (/servlet/Ch1servlet) is not available.
    7) i have uncommented(it comes preconfigured) the invoker part in web.xml.
    I have tried including servlet in an package and without package
    I am not sure if its problem with server configuration orelse problem with my file placing.
    Please let me know if you have any idea what went wrong.

    I found this, unable to copy it, so i am typing it:
    Feb11,2008 11:55:57 AM org.apache.catalina.core.AprLifecycleLIstener init
    INFO: The Apache Tomcat Native Library which allows optimal performance in production environemnt was not found on the java.library.path:c:\program Files\Java\jdk1.6.0\bin;....
    last line says
    org.apache.cataline.startup.catalina start
    INfo: Server startup in 657ms

Maybe you are looking for

  • Console keeps opening

    I have a Macbook Air with Mavericks. When I startup from shutdown or sleep mode, the Console application opens up. Is there a way for this not to occur?

  • Faxing reports from ORACLE PURCHASING

    If anyone has faxed purchase orders from ORACLE Application using some third party tool other than oracle reports ,kindly let me know at [email protected]

  • Snow Leopard on new 2011 MacBook Pro?

    I need to buy a new MacBook pro, as my early 2008 model just died on a road gig (4 months out of warranty) but most of my drafting software has been found to be incompatible with lion, is it possible/simple to put snow leopard on a brand new MBP 15"?

  • Edit in lower bitrate and export in higher bitrate

    Is there a way i can edit HD movie in a lower bitrate for better workflow, and then when im finished edititing the movie, i can export the movie out in original HD bitrate.

  • Components for MultiSim

    Hi, Can anyone point me, or send me, to a site where I can download the Intel family' components, including 8088, 8086 and their interfacing IC's, to add them to the MULTISIM. Thanks in Advance Salah