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

Similar Messages

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

  • 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

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

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

  • Javax.servlet.* not found

    I am importing a package called
    import javax.servlet.*;
    but it shows me error that it doesnt find this package ..
    I have searched the src.zip file, it contains the javax folder but the javax folder doesnt contain the servlet folder inside it. please help me wut shud i do

    Hi,
    You have to put servlet.jar in your classpath. If you are using Tomcat it is in common/lib folder of tomcat directory. Hope this will help.
    Regards
    Sekhar

  • Javax.smartcardio package not found in Java source file

    I downloaded the latest JDK from developer.apple.com, but now I cannot find the javax.smartcardio package in the source package (src.jar) that came with it. I unpacked the JAR file, but simply can't find the stated package. Can you help me out?

    I can confirm the issue here (Mountain Lion, 10.8.5). A very simple program (attached below) that just enumerates terminals and checks if a card is present will crash:
    If Apple JDK6 is used in 64-bit mode (without supplying the -d32 argument)
    If Oracle JDK7 is used (can not switch to 64-bit, uses)
    It will work if:
    If Apple JDK6 is forced into 32-bit mode using -d32
    If Oracle JDK7 version of libj2pcsc.dylib is replaced with a patched version
    javax.smartcardio on Mac OS X is in a truly sad state. :-(
    Can anyone suggest alternatives for Smartcard communication on Mac OS X fat clients?
    package com.example.smartcardio;
    import javax.smartcardio.CardTerminal;
    import javax.smartcardio.CardTerminals;
    import javax.smartcardio.TerminalFactory;
    public class TestWaitForChanges {
              public static void main(String[] args) throws Exception {
                        CardTerminals terminals = TerminalFactory.getDefault().terminals();
                        while (true) {
                                  for (CardTerminal terminal : terminals.list()) {
                                            System.out.println("Checking terminal: " + terminal.getName());
                                            System.out.println("Card present: " + (terminal.isCardPresent() ? "YES" : "NO"));
                                  System.out.println("Waiting for changes...");
                                  terminals.waitForChange();

  • Import javax.telephony.* not found.

    Hello,
    I am working on my first JTAPI exaples. I got this error. Can any one tell me how to over come this. What .jar file should I include in my class path. I am using jdk1.4.0 on Win XP.
    Thanks
    James

    Hello,
    Thanks for your reply. I have downloaded the class files. I downloaded the jtapi12-class.zip file to desktop and unzipped to jtapi directory in the desktop. I copied the jtapi folder to c:\j2sdk1.4.0\lib and c:\j2sdk1.4.0\jre\lib directory. I have the classpath in my autoexec.bat file like this
    set path=c:\j2skd1.4.0\bin;
    set classpath=%classpath%;.;
    I still get that error as class not found or the import statement not found. Did I do any mistake, Please rectify me.
    Thanks
    James

  • Javax package not found

    Hi,
    I installed jdk1.4 in my system.And i type one swing concept program.After compilation of that program.It shows error like Javax.Swing. package not found.Please help to me to clear the proble.And also Javax.servlet package also not taken.
    regards
    sridhar

    Its javax, not Javax.

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

  • Package not found in import

    Hello, I�m trying to run a webapplication but I get an Error 500-message in the browser(IE 5): Package not found in import. It is an webapplication with JSPs and an controlling servlet. Does anyone know how to fix that problem?
    Using: Windows 2000, Tomcat 3.2.1 as NT-service, JavaTM 2 SDK, Enterprise Edition, JavaTM 2 SDK, Standard Edition
    Tomcat/webapps/projektverwaltung.war
    Error: 500
    Location: /projektverwaltung/projektverwaltung/JSP/Menue.jsp
    Internal Servlet Error:
    org.apache.jasper.JasperException: Unable to compile class for JSPC:\Tomcat\work\localhost_8080%2Fprojektverwaltung\_0002fprojektverwaltung_0002fJSP_0002fMenue_0002ejspMenue_jsp_0.java:15: Package de.zebulon.projektverwaltung.projekttool not found in import.
    import de.zebulon.projektverwaltung.projekttool.*;
    ^
    1 error
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:254)
         at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:462)
         at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
         at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:433)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:152)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:164)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
         at org.apache.tomcat.core.Handler.service(Handler.java:286)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
         at java.lang.Thread.run(Thread.java:484)
    CLASSPATH: .;C:\;C:\jesdkee1.3\lib\j2ee.jar;C:\jdk1.3.0_01\lib\tools.jar;C:\Tomcat\lib\servlet.jar;C:\de\zebulon\projektverwaltung\projekttool;
    J2EE_CLASSPATH:
    C:\mysql\JDBC_MySQL_mm\mm.mysql-2.0.4-bin.jar;C:\mysql\JDBC_MySQL_Resin\caucho-jdbc-mysql-0.2.2.jar;C:\mysql\JDBC_MySQL_twz\twz1\jdbc\mysql\htdocs\twz1jdbcForMysql.jar;
    J2EE_HOME:
    C:\j2sdkee1.3;
    JAVA_HOME:
    C:\jdk1.3.0_01;
    TOMCAT_HOME:
    C:\tomcat;
    Path:
    C:\PROGRA~1\Borland\Delphi5\Projects\Bpl;C:\PROGRA~1\Borland\Delphi5\Bin;C:\PROGRA~1\BORLAND\CBUILD~1\BIN;C:\PERL\BIN;"%PATH%";%SYSTEMROOT%;%SYSTEMROOT%\system32;%SYSTEMROOT%\system32\WBEM;C:\jdk1.3.0_01\bin;C:\j2sdkee1.3\bin;C:\j2sdkee1.3\lib\j2ee.jar;C:\mysql\bin;
    Server.xml entry:
    <Context path="/projektverwaltung"
    docBase="webapps/projektverwaltung"
    defaultSessionTimeOut="30"
    debug="9">
    </Context>
    Web.xml:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
    <display-name>Projektverwaltung Zebulon</display-name>
    <description>Interne Projektverwaltung Fa. Zebulon</description>
    <welcome-file-list>
    <welcome-file>menue.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
    <servlet-name>ProjektServlet</servlet-name>
    <display-name>ProjektServlet</display-name>
    <description>Servlet das die Applikation kontrolliert</description>
    <servlet-class>de.zebulon.projektverwaltung.projekttool.ProjektServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <url-pattern>/Projekttool</url-pattern>
    <servlet-name>ProjektServlet</servlet-name>
    </servlet-mapping>
    <session-config>
    <session-timeout>30</session-timeout>
    </session-config>
    </web-app>

    Hello, I try copy C:\de\zebulon\projektverwaltung\projekttool\*.class in
    location that contain file _002fprojektverwaltung_0002fJSP_0002fMenue_0002ejspMenue_sp_0.java.

  • ANT script genrated error: package javax.servlet does not exist

    Hi there,
    I am running ANT and confronted this message:
        [javac] Compiling 1 source file to C:\eclipseProjects\tomcat_test
        [javac] C:\eclipseProjects\tomcat_test\WEB-INF\src\WebTest.java:4: package javax.servlet does not exist
        [javac] import javax.servlet.ServletException;
        [javac] ^I googled around and found this solution:
    servlet-api.jar is the jarfile that contains javax.servlet.ServletException and javax.servlet.http.* which are imported by WebTest.java and must therefore be found in the classpath. If javac doesn't find this jar (or the javax.servlet packages), it will say (or shout, depending on my and javac's mood): [the error message]
    well...I set in the classpath the location of the servlet-api.jar
    (found at: C:\Tomcat\common\lib)
    I set it with the environment variable (windows xp)
    Just as it's shown here: http://www.cs.usask.ca/~wew036/latex/env-env.jpg
    NOTHING :-(
    could anyone assist, thanks

    Hi..seems u r new to J2ee.. dont worry its a very small problem:
    Here is the solution.. yes u have to edit the environment variables:..
    I am using J2EE sdk 1.4 and running on xp
    This is the classpath setting:
    C:\Sun\AppServer\lib\j2ee.jar;
    This is the PATH setting
    C:\Sun\AppServer\bin;
    Good Luck :)

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

  • Help - Tomcat - Package not found in import

    Error: 500
    Location: /htmltest/login.jsp
    Internal Servlet Error:
    org.apache.jasper.JasperException: Unable to compile C:\jdk1.3.1\jakarta-tomcat-3.3a\work\DEFAULT\htmltest\login_1.java:5: Package usingjsp not found in import.
    import usingjsp.*;
    ^
    1 error
         at org.apache.tomcat.facade.JasperLiaison.javac(Unknown Source)
         at org.apache.tomcat.facade.JasperLiaison.processJspFile(Unknown Source)
         at org.apache.tomcat.facade.JspInterceptor.requestMap(Unknown Source)
         at org.apache.tomcat.core.ContextManager.processRequest(Unknown Source)
         at org.apache.tomcat.core.ContextManager.internalService(Unknown Source)
         at org.apache.tomcat.core.ContextManager.service(Unknown Source)
         at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Unknown Source)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:484)
    Above is the error I encounter when running my JSP and Servlets combination under Tomcat3.3a
    Can anyone pls tell me basically what error is that?
    The path for my package "usingjsp" is c:\jdk13~1.1\jakart~1.3a\webapps\examples\web-inf\classes\usingjsp
    I put my package under that directory because to my knowledge Tomcat requires all servlet to be put under there by default.
    The path for my JSP file is c:\jdk13~1.1\jakart~1.3a\webapps\htmltest.
    NOTE: I had modified the XML file.
    Under that folder there is 2 classes named LoginServlet and UserDataTable.
    Below are my codes:
    1. logintest.html
    <html>
    <body>
    <form action="login.jsp" method="post">
    <table>
    <tr><td>Username: <td><input type="text" name="username">
    <tr><td>Password: <td><input type="password" name="password">
    </table>
    <input type="submit" value="SUBMIT">
    </form>
    </body>
    </html>
    2. login.jsp
    <%@ page language="java" import="java.util.*" %>
    <%@ page import="usingjsp.*" %>
    <html>
    <body bgcolor="#a3355f">
    <%
         String userName = request.getParameter("username");
         String password = request.getParameter("password");
         String userKey = UserDataTable.createUserData();
         Hashtable userData = UserDataTable.getUserData(userKey);
         userData.put("username", userName);
    %>
    <form action="/examples/servlet/LoginServlet" method="post">
    <input type="hidden" name="userKey" value="<%userKey%>">
    <input type="submit" value="SUBMIT">     
    </form>
    </body>
    </html>
    3. LoginServlet.java
    //package usingjsp;
    import javax.servlet.*;
    import java.io.*;
    import java.util.*;
    public class LoginServlet extends GenericServlet {
         public void service(ServletRequest req, ServletResponse res) throws IOException {
              res.setContentType("text/html");
              PrintWriter out = res.getWriter();
              String userKey = req.getParameter("userKey");
              Hashtable userData = new Hashtable();
              UserDataTable temp = new UserDataTable();
              userData = temp.getUserData(userKey);
              if (userData == null) {
                   out.println("<html>");
                   out.println("<body>");
                   out.println("<h1>SORRY<h1>");
                   out.println("</body>");
                   out.println("</html>");
                   return;
              String userName = (String)userData.get("username");
                   out.println("<html>");
                   out.println("<body>");
                   out.println("<h1>" + userName + "<h1>");
                   out.println("</body>");
                   out.println("</html>");
    4. UserDataTable.java
    //package usingjsp;
    import java.util.*;
    public class UserDataTable {
         protected static Hashtable userData = new Hashtable();
         protected static Random keyGenerator = new Random();
         public static String createUserData() {
              String userKey = "" + keyGenerator.nextLong();
              userData.put(userKey, new Hashtable());
              return userKey;
         public static Hashtable getUserData(String userKey) {
              if (userKey == null) return null;
                   return (Hashtable) userData.get(userKey);
         public static void clearUserData(String userKey) {
              if (userKey == null) return;
                   userData.remove(userKey);
    }Pls let me know if you need more info. Thanks!

    1. login.jsp
    <%@ page language="java" import="java.util.*" %>
    <%@ page import="classes.servlets.*" %>
    <html>
    <body bgcolor="#a3355f">
    <%
         String userName = request.getParameter("username");
         String password = request.getParameter("password");
         String userKey = UserDataTable.createUserData();
         Hashtable userData = UserDataTable.getUserData(userKey);
         userData.put("username", userName);
    %>
    <form action="/classes/servlet/LoginServlet" method="post">
    <input type="hidden" name="userKey" value="<%userKey%>">
    <input type="submit" value="SUBMIT">     
    </form>
    </body>
    </html>
    2. UserDataTable.java
    package classes.servlets;
    import java.util.*;
    public class UserDataTable {
         protected static Hashtable userData = new Hashtable();
         protected static Random keyGenerator = new Random();
         public static String createUserData() {
              String userKey = "" + keyGenerator.nextLong();
              userData.put(userKey, new Hashtable());
              return userKey;
         public static Hashtable getUserData(String userKey) {
              if (userKey == null) return null;
                   return (Hashtable) userData.get(userKey);
         public static void clearUserData(String userKey) {
              if (userKey == null) return;
                   userData.remove(userKey);
    3. LoginServlet.java
    package classes.servlets;
    import javax.servlet.*;
    import java.io.*;
    import java.util.*;
    public class LoginServlet extends GenericServlet {
         public void service(ServletRequest req, ServletResponse res) throws IOException {
              res.setContentType("text/html");
              PrintWriter out = res.getWriter();
              String userKey = req.getParameter("userKey");
              Hashtable userData = new Hashtable();
              UserDataTable temp = new UserDataTable();
              userData = temp.getUserData(userKey);
              if (userData == null) {
                   out.println("<html>");
                   out.println("<body>");
                   out.println("<h1>SORRY<h1>");
                   out.println("</body>");
                   out.println("</html>");
                   return;
              String userName = (String)userData.get("username");
                   out.println("<html>");
                   out.println("<body>");
                   out.println("<h1>" + userName + "<h1>");
                   out.println("</body>");
                   out.println("</html>");
    }I had added CLASSPATH=c:\jdk13~1.1\jakart~1.3a\webapps\internet\web-inf into autoexec.bat.
    I had been able to compile UserDataTable.java and LoginServlet.java.
    Path for UserDataTable = c:\jdk13~1.1\jakart~1.3a\webapps\internet\web-inf\classes\servlets\UserDataTable.java
    Path for LoginServlet = c:\jdk13~1.1\jakart~1.3a\webapps\internet\web-inf\classes\servlets\UserDataTable.java
    server.xml<?xml version="1.0" encoding="ISO-8859-1"?>
    <Server>
        <!-- You can add a "home" attribute to represent the "base" for
             all relative paths. If none is set, the TOMCAT_HOME property
             will be used, and if not set "." will be used.
             webapps/, work/ and log/ will be relative to this ( unless
             set explicitely to absolute paths ).
          -->
        <ContextManager workDir="work" >
          <!-- ==================== Global modules ==================== -->
            <LoaderInterceptor11  useApplicationLoader="true" />
            <TrustedLoader />
            <LogSetter name="tc_log" timestamps="true"
                 verbosityLevel="INFORMATION"  />
            <LogEvents enabled="false" />
            <!-- Backward compat: read the Context declarations from server.xml-->
            <ContextXmlReader config="conf/server.xml" />
            <!-- Separated Context -->
            <ContextXmlReader config="conf/apps.xml" />
            <AutoDeploy source="modules" target="modules"
                  redeploy="true" />
            <AutoWebApp dir="modules" host="DEFAULT" trusted="true"/>
            <AutoDeploy source="webapps" target="webapps" />
            <AutoWebApp dir="webapps" host="DEFAULT" />
            <PolicyLoader securityManagerClass="java.lang.SecurityManager"
                    policyFile="conf/tomcat.policy" />
            <SimpleMapper1 />
            <SessionExpirer checkInterval="60" />
            <!-- For development you can use randomClass="java.util.Random" -->
            <SessionIdGenerator randomClass="java.security.SecureRandom"
                                randomFile="/dev/urandom" />
            <!-- ========== context processing modules ========== -->
            <!-- This will be the "default" profile
                 ( all except the "global" modules can be set per context )
              -->
            <LogSetter name="servlet_log"
                 timestamps="true"
                 verbosityLevel = "INFORMATION"
                 path="logs/servlet-${yyyyMMdd}.log"
                 />
            <LogSetter  name="JASPER_LOG"
                 timestamps="true"
                 path="logs/jasper-${yyyyMMdd}.log"
                 verbosityLevel = "INFORMATION"  />
            <WebXmlReader validate="true" />
            <ErrorHandler showDebugInfo="true" />
            <WorkDirSetup cleanWorkDir="false" />
            <Jdk12Interceptor />
            <!-- Non-standard invoker, for backward compat. ( /servlet/* ) -->
            <InvokerInterceptor />
            <!-- you can add javaCompiler="jikes" -->
            <JspInterceptor keepGenerated="true"
                   largeFile="false"
                   useJspServlet="false"
                   />
            <StaticInterceptor listings="true" />
            <ReloadInterceptor fullReload="true" />
            <SimpleSessionStore maxActiveSessions="-1" />
            <AccessInterceptor />
            <CredentialsInterceptor />
            <SimpleRealm  filename="conf/users/global-users.xml" />
           <!-- UnComment the following and comment out the
                above to get a JDBC realm.
                Other options for driverName:
                  driverName="oracle.jdbc.driver.OracleDriver"
                  connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
                  connectionName="scott"
                  connectionPassword="tiger"
                  driverName="org.gjt.mm.mysql.Driver"
                  connectionURL="jdbc:mysql://localhost/authority"
                  connectionName="test"
                  connectionPassword="test"
                "connectionName" and "connectionPassword" are optional.
            -->
            <!--
            <JDBCRealm
                debug="99"
             driverName="sun.jdbc.odbc.JdbcOdbcDriver"
             connectionURL="jdbc:odbc:TOMCAT"
             userTable="users"
                userNameCol="user_name"
                userCredCol="user_pass"
             userRoleTable="user_roles"
                roleNameCol="role_name" />
            -->
            <LoadOnStartupInterceptor />
            <Servlet22Interceptor />
            <!-- Tag pooling support.
                 To enable the reuse of tag handlers as described in
                 the JSP spec, uncomment the following.  If your pages
                 use a lot of custom tags, you should see a nice performance
                 gain.
                 Note that placing the interceptor here will enable
                 Tag pooling for all of the web applicatitions loaded -
                 this may be a bad thing if all tags are not coded to
                 handle reuse. To enable pooling only for specific web
                 applications i.e. Contexts, place the interceptor inside of
                 the Context's definition.
                 To view information about tag usage uncomment the tag
                 LogSetter. Set verbosityLevel to DEBUG to see everytime
                 a tag is obtained and released.
            -->
            <!--
            <LogSetter  name="tag_pool_log" timestamps="true"
                path="logs/tagpool-${yyyyMMdd}.log"
                verbosityLevel="INFORMATION" />
            <TagPoolManagerInterceptor />
            -->
            <!-- Request processing -->
            <DecodeInterceptor />
            <SessionId cookiesFirst="true" noCookies="false" />
            <!-- Automatic config generation
                 Set noRoot="false" if you wish to have Tomcat try to take
                   control of the external web server's root context.
                   Additonal configuration of the external web server may be
                   required for this to be successful.
                 Note: Configuration files are not written as part of the
                   default startup behvior.  Append "jkconf" to the startup
                   command to have Tomcat initialize, write the config files,
                   then exit. This may be done while Tomcat is running.
              -->
            <ApacheConfig noRoot="true" />
            <IISConfig noRoot="true" />
            <NSConfig noRoot="true" />
             <!-- Uncoment for apache-style logs
                  Attributes: logFile, flush, format
            <AccessLogInterceptor/>
              -->
          <!-- ==================== Connectors ==================== -->
           <!-- new http adapter. Attributes:
                   secure - use SSL ( https )
                   keystore, keypass - certs for SSL
                   port
                   reportedname - Server name to send back to browser
                                  by default report Tomcat Web Server ...
                                  set an empty string to avoid sending server header
            -->
            <Http10Connector   port="8080"
                      secure="false"
                      maxThreads="100"
                      maxSpareThreads="50"
                      minSpareThreads="10" />
            <!--
                Uncomment this for SSL support. You _need_ to set up a
                server certificate if you want this to work, and you
                need JSSE. See tomcat-ssl-howto.html for more detailed
                instructions.
                1. Make the JSSE jars available to Tomcat, either by making
                   them an installed extension or by adding them to the
                   Tomcat CLASSPATH.
                2. Do: keytool -genkey -alias tomcat -keyalg RSA
                   RSA is essential to work with Netscape and IIS.
                   Use "changeit" as password. ( or add keypass attribute )
                   You don't need to sign the certificate.
             -->
            <!--
            <Http10Connector  port="8443" secure="true" />
            -->
            <!--
                 JNI connector. It assumes the library is located in
                 TOMCAT_HOME/bin/native/jni_connect.[dll, nlm, so]. or in LD_LIBRARY_PATH.
                 For different paths set "nativeLibrary" parameter.
                 The JniConnector will be self-enable only if JNI mode is detected.
             -->
            <JniConnector />
            <!-- Apache AJP12 support. This is also used to shut down tomcat.
                 Parameter "address" defines network interface this Interceptor
                 "binds" to. Add it if you want to "bind" to just "127.0.0.1".
                 address="127.0.0.1"
                 Parameter "tomcatAuthentication", controls if Tomcat honors
                 ( and uses ) auth done in HTTP Server or not, when true Tomcat does
                 not use in any way auth information provided by the HTTP Server.
                 true is the default.
                 tomcatAuthentication="false"
              -->
            <Ajp12Connector      port="8007" />
            <!-- Apache AJP13 support (mod_jk)
                 Parameter "address" defines network interface this Interceptor
                 "binds" to. Add it if you want to "bind" to just "127.0.0.1".
                 address="127.0.0.1"
                 Parameter "tomcatAuthentication", controls if Tomcat honors
                 ( and uses ) auth done in HTTP Server or not, when true Tomcat does
                 not use in any way auth information provided by the HTTP Server.
                 true is the default.
                 tomcatAuthentication="false"
              -->
            <Ajp13Connector port="8009" />
          <!--
               Context definitions can be placed here ( not recommended ) or
               in separate files. The ContextXmlReader will read all context
               definitions ( you can customize the "base" filename ).
               The default is conf/apps-[name].xml.
               See conf/apps-examples.xml and conf/apps-admin.xml 
           -->
    <Context path="/internet"
    docBase="webapps/internet"
    crossContext="true"
    debug="0"
    reloadable="true"
    trusted="false" >
    </Context>
        </ContextManager>
    </Server>The directory structure is:
    <c:\>
        <jdk13~1.1>
            <jakart~1.3a>
                <webapps>
                    <internet>
                        <jsp>
                        <web-inf>
                            <classes>
                                <servlets>
                                <beans>P/S: Actually, I would want to add c:\jdk13~1.1\jakart~1.3a\webapps into CLASSPATH, so that I can use the package as internet.web-inf.classes.servlet (instead of current version of classes.servlet).
    However, the compiler would not let me compile because it says ";" expected at web-inf (I think the hyphen is not allowed). Is there any other solution?
    Thanks and sorry to bother you again!

  • Package javax.servlet does not exist

    Trying to learn servlets. just installing software & tesing install.
    What I have done:
    1. read Deitel text, and written & tested applications and applets..even on my web site. surprise surprise.
    2. installed J2Std Edition and did applications & applets.
    3. Wanted to do servlets so downloaded and installed TOMCAT(got their index html so looks like it is at least running).
    4. Took Deitel servlet pgm example and tried to compile, but got the subject msg and others concening methods i expect to be in the include.
    5. After reading lots decided maybe I need to install J2EE to do servlets(I dont see where Deitel tells me I need to do this).
    6. Went to SUN, downloaded and installed J2EE. Im on NT 4.0 so I set JAVA_HOME and J2EE_HOME.
    7. Read topics this forum, so I found servlet.jar in my TOMCAT dir, copied it to jdk1.3.1\jre\bin and jdk1.3.1\jre\lib.
    8. set CLASSPATH to one of these.
    9 STILL get the error. I appreciate any help you can give. Im very new to SUN and am just blindly trying to follow what Dietel tells me to do. I love the JAVA part of the text, but the way they explain the software installs is very poor.
    The jar file is listed as an executable, so I assume I dont need to do any type of unpacking like with a zip file. A puzzle to me is that the text talks about the INCLUDE stmts pointing to directory structurs/file names, but I cant find many of them.. they mmust be hidden in some other pack files I guess because all applications and applets are compiling and running just fine.
    I there any documentation(at SUN or elsewhere) that kind of explains in English to the uninitiated how the different SUN products/packages work together/seperately.. when each one is necessary??
    Thanks for your help [email protected]

    Grayman,
    An application server like Tomcat needs access to a java runtime environment and all the libraries referenced from the application code that you deploy on it.
    So maybe try debugging like this :
    1)first check all your imports in the code
    especially
    import javax.servlet.*;
    import javax.servlet.http.*;
    2) Browse trough the tomcat documentation to see which runtime environment it is running on top of. This could be something like C:\JDK1.2\.. but could be also be C:\program files\java\JDK1.2\.. or
    even (I dont know Tomcat very well) c:\Program Files\Tomcat\bin\Jdk1.2\
    3) Once you have found which is the runtime environment for your application server, you can assume that all .jar-packaged libraries in ...\JDK1.2\lib\ are available to your code. So you could copy servlets.jar to that directory.
    4) make sure to restart Tomcat.
    if you want to check which Classes are available in a .jar - file, do this: 1)open a dos prompt 2)Set PATH=%PATH%;C:\...\JDK1.2\bin (i.e include the jar-utility) as a command line program
    3)cd to the directory where the .jar-file can be found (ex: C:\JDK1.2\lib\rt.jar)
    4) type: jar -tvf rt.jar
    you should see the content on your screen
    java.awt.Textbox.class
    java.awt. etc..
    good luck
    Papyrus

Maybe you are looking for

  • PHP and MySQL Connection problem

    I am trying to make a PHP MySQL on a remote server connection in Dreamwesaver CS3. When I enter the information (host, user, password, etc.) and hit TEST, I get the following error message. "Access Denied. The file may not exist, or there could be a

  • Runtime error in functional module

    they given below program is a function module calling program.while am execute this program they could display the message like as What happened?     Error in ABAP application program.     The current ABAP program "YSUSFUN1" had to be terminated beca

  • What is the best iPod for me?

    I have an iPod Touch 4th Generation and when iTunes stops covering it, I want to get a new device for music. I really don't play games on it, but I need something that has a lot of storage for my music, has good sound, and fairly inexpensive. I was l

  • Website name does not appear

    My website name does appear on yahoo or google. The website is burgerburgerny. I do not see burgerburgerny, only "main page" Ernest

  • Best External Drive for MacPro and iMovie

    In using iMovie, I find my existing main drives filling up, and need to get a fast external drive which works well with the Mac Pro and the snow leopard operating system. I note that there is a new usb 3.0 standard, but my understanding is that it do