Help compiling BookStore  SERVLETS tutorial classes

I am new to Java. Please be patient with my errors. I need help with compiling the servlets given as part of the SERVLET tutorial. I have previously installed JDK1.3.1.01. I have also downloaded the JSDK2.1 as part of the tutorial. As part of the tutorial several servlet classes were provided. Almost all of them have these import statements.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
However, the javac is unable to compile the classes. I think it is because javax.servlet is installed under /root/jsdk and JDK is installed under /usr/java/jdk1.3/bin. I can find the javax directory under /root/jsdk but not under /usr/java. I tried giving the classpath option to javac as:
javac -classpath /root/jsdk BookStoreServlet.java
But it did not work.
I believe once the servlet classes are compiled it will be possible to view them from the JSDK browser. I was able to successfully start the jsdk browser with startserver script given with the distribution. And the example SnoopServlet worked fine.
In summary, I believe the authors of the tutorial left out the details of compiling the classes and viewing from browser. I could be wrong about it.
I will appreciate any help from the users of the tutorial and anyone who knows servlets.
Many thanks.
Murthy

i found this info on how to set the classpath in linux
http://java.sun.com/products/jdk/1.2/docs/tooldocs/sola
is/classpath-linux.htmlThanks imp-cat. I could compile the BookStoreServlet.java into its corresponding class. I get the following error when I try to run it. What should I do? Thanks. Regards. Murthy
java BookStoreServlet
Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
     at java.lang.ClassLoader.defineClass0(Native Method)
     at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
     at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
     at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)

Similar Messages

  • Compiling a servlet with utility class

    Hello,
    I am having trouble compiling a servlet that uses a utility class.
    The compiler doesn't seem to recognize the utility class for some reason.
    my classpath is set to:
    .;C:\ServletDevel;C:\Program Files\Apache Software Foundation\common\lib\servlet-api.jar
    the error:
    Cannot find symbol: ServletUtilities
    the servlet code:
    package coreservlets;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    /** test the use of packages and utilities on the server */
    public class helloservlet3 extends HttpServlet {
    public void doGet(HttpServletRequest request,
                   HttpServletResponse response)
                   throws ServletException, IOException {
         response.setContentType("text/html");
         PrintWriter out = response.getWriter();
         String title = "Hello (3)";
         out.println(ServletUtilities.headWithTitle(title) +
              "<body bgcolor=\"#FDF5E6\">\n" +
              "<h1>" + title + "</h1>\n" +
              "</body></html>");
    the utility class:
    package coreservlets;
    import javax.servlet.*;
    import javax.servlet.http.*;
    /** time saving static methods */
    public class ServletUtilities {
         public final static String docType =
         "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
         "Transitional//EN\">";
    public static String headWithTitle(String title){
    return (docType + "\n" + "<html>\n" +
              "<head><title>" + title + "</title></head>\n");
    any help wouldbe greatly appreciated.

    Nope still getting an error
    helloservlet3.java:17:cannot find symbol
    symbol : class ServletUtilities
    location: package coreservlets
    out.println(coreservlets.ServletUtilities.headWithTitle(title) +
    thanks for the help, i'll keep on trying to figure it out.

  • Help: Compiling servlets

    Hi,
    I have created a servlet java file.
    and when i compile the servlet java file, I am getting error,
    HelloWorld.java:2: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    HelloWorld.java:3: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    HelloWorld.java:5: cannot find symbol
    symbol: class HttpServlet
    public class HelloWorld extends HttpServlet {
    ^
    HelloWorld.java:7: cannot find symbol
    symbol : class HttpServletRequest
    location: class HelloWorld
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    ^
    HelloWorld.java:7: cannot find symbol
    symbol : class HttpServletResponse
    location: class HelloWorld
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    ^
    HelloWorld.java:8: cannot find symbol
    symbol : class ServletException
    location: class HelloWorld
    throws ServletException, IOException {
    ^
    6 errors
    where can i get the missing javax classes?
    Thanks and Regards,
    Rashmy.

    Hi Sreekanth,
    Yes, I am using Tomcat server.
    I have java SDK 6 and J2EE 5.
    I am setting up the path to jdk6 and compiling it.
    is this the correct way?
    and i tried settingup calss path to the servlet-api.jar. but getting the same error.
    Thanks,
    Rashmy.

  • Help compiling with .class files

    I am using JGrasp and I am trying to compile a program that uses .class files instead of the .java files, but JGrasp will not recognize these at compile time. How do I get my program to compile with these .class files?

    I prefer using Jenuity:
    [http://www.nmmu.ac.za/jenuityIDE]
    It's much simpler to use than JGrasp and isn't nearly as confusing.
    For the record, you compile .java files into .class files. There is no need to "compile" existing .class files. If you have the class files you can run them from the command line. e.g. if you have a class file named Orange.class you should be able to type "java Orange" from the command line to run it. If Orange is inside a directory structure based on packages you may need to execute this command from just outside the 'highest" folder.
    If you just need to link to these class files, copy them into the "/jre/lib/ext" folder of your JDK.

  • 10 Duke Dollars if you help me set up tutorial

    After several posts to this forum w/o any success, I am now offering 10 Duke Dollars to get this problem fixed:
    I am trying to work through the j2ee tutorial on a Windows XP platform, specifically the servlets section which requires me to build the bookstore1 example (chapter 11). I am having problems with using asant to compile and package the project. I have been at a complete standstill for about a week now because I cant get the example to run - Im tearing my hair out, so plese help me!!!
    The command I am using is asant create-bookstore-war. This throws about 80 compilation errors because classes referenced within the source files are not found . I therefore know that the compiler cant find the classes (suggesting CLASSPATH problems), but I dont know what settings Im supposed to be using.
    Some info for you:
    I tried adding JAVA_HOME and J2EE_HOME to the environemt variables, pointing to the java sdk (inside the app server) and J2EE application server installation location respectively. This didnt work. Initially I had JAVA_HOME pointing to a seperate installation of the SE SDK I had, but since discovering the SDK inside the appserver, I uninstalled J2EE, J2SE SDK, and re-installed J2EE, using the enclosed sdk as JAVA_HOME. None of this solved my problem.
    I think I know now that the environment variables are not anything to do with the tutorial - this is just for the locations of the J2EE and J2SE SDK command path files - is this correct? In which case, using J2EE_HOME and JAVA_HOME is just for shorthand declarations in the environemtn/system variables?
    (As you can probably guess by now I have spent a lot of time trying out different things!!!).
    I also tried setting the j2ee.home and j2ee.tutorial.home attributes in the build.propoperties file located in <INSTALL>/j2eetutorial14/examples/common. This didnt work. I also tried setting the admin username property in this file, and the corresponding password in the password file (cant remember offhand what its called). Again, no luck.
    In another post, somebody asked for the following oputput from my system:
    D:\J2EE\j2eetutorial14\examples\web\bookstore1>asant listprops
    Buildfile: build.xml
    listprops:
         [echo] Path information
         [echo] j2ee.home = C:\Sun\AppServer
         [echo] env.Path = C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C
    :\BORLAND\BCC55\BIN;C:\Sun\AppServer\jdk\bin;C:\Sun\AppServer\bin;
         [echo] env.PATH = ${env.PATH}
         [echo] Classpath information
         [echo] classpath = .;D:\Packages;
         [echo] Admin information
         [echo] admin.password = ${admin.password}
         [echo] admin.host = localhost
         [echo] admin.user = admin
         [echo] admin.port = 4848
         [echo] https.port = 8181
         [echo] Domain information
         [echo] domain.resources = "domain.resources"
         [echo] domain.resources.port = 8080
         [echo] Database information
         [echo] db.root = C:\Sun\AppServer/pointbase
         [echo] db.driver = com.pointbase.jdbc.jdbcUniversalDriver
         [echo] db.host = localhost
         [echo] db.port = 9092
         [echo] db.sid = sun-appserv-samples
         [echo] db.url = jdbc:pointbase:server://localhost:9092/sun-appserv-samples
         [echo] db.user = pbpublic
         [echo] db.pwd = pbpublic
         [echo] url.prop = DatabaseName
         [echo] ds.class = com.pointbase.jdbc.jdbcDataSource
         [echo] db.jvmargs = -ms16m -mx32m
    BUILD SUCCESSFUL
    Total time: 1 second
    D:\J2EE\j2eetutorial14\examples\web\bookstore1>There must be somebody out there who has set this tutorial set up on Windows XP - please can you give me a dump of your system and environment variables, and any other settings I need (build.properties etc.).
    Many thanks

    Heres the last couple of errors on running asant creat-bookstore-war. All errors are cannot resolve symbol, so im sure its a classpath problem.
    I only have PATH properties set in the environment variables, and the set CLASSPATH only points to my own J2SE packages.
        [javac] D:\J2EE\j2eetutorial14\examples\web\bookstore1\src\servlets\ShowCart
    Servlet.java:147: cannot resolve symbol
        [javac] symbol  : class ShoppingCartItem
        [javac] location: class servlets.ShowCartServlet
        [javac]                 ShoppingCartItem item = (ShoppingCartItem) i.next();
        [javac]                                          ^
        [javac] D:\J2EE\j2eetutorial14\examples\web\bookstore1\src\servlets\ShowCart
    Servlet.java:148: cannot resolve symbol
        [javac] symbol  : class BookDetails
        [javac] location: class servlets.ShowCartServlet
        [javac]                 bd = (BookDetails) item.getItem();
        [javac]                       ^
        [javac] 68 errors
    BUILD FAILED
    file:D:/J2EE/j2eetutorial14/examples/web/bookstore1/build.xml:56: Compile failed
    ; see the compiler error output for details.
    Total time: 8 seconds
    D:\J2EE\j2eetutorial14\examples\web\bookstore1> and heres the build.properties file:
    j2ee.home=C:\\Sun\\AppServer
    j2ee.tutorial.home=D:\\J2EE\\j2eetutorial14
    sunone.home=${j2ee.home}
    admin.password.file=${j2ee.tutorial.home}/examples/common/admin-password.txt
    admin.host=localhost
    admin.user=colr
    admin.port=4848
    https.port=8181
    domain.resources="domain.resources"
    domain.resources.port=8080
    db.root=${j2ee.home}/pointbase
    db.driver=com.pointbase.jdbc.jdbcUniversalDriver
    db.host=localhost
    db.port=9092
    db.sid=sun-appserv-samples
    db.url=jdbc:pointbase:server://${db.host}:${db.port}/${db.sid}
    db.user=pbpublic
    db.pwd=pbpublic
    url.prop=DatabaseName
    ds.class=com.pointbase.jdbc.jdbcDataSource
    db.jvmargs=-ms16m -mx32m Thanks.

  • How to insert the new Servlet Api Class files?

    Hi,
    I need to know how do I add the Servlet Api Class to my java directory
    after i download it from the net? Thanks for your help in advance!

    niceguyme,
    If you downloaded the J2EE 1.3.1 API and installed it to (for example) c:\j2ee131, then what you need to add to your class path is:
    c:\j2ee131\lib\j2ee.jar
    I also add c:\j2ee131\lib\ejb10deployment.jar to the classpath, but it is not necessary.
    there are several ways to add these to your classpath. It depends on what Operating System you are using. On windows 98 type OS, you can edit the autoexec.bat and add these directly to your already existing classpath. Windows NT,2000, and XP: you can add them to the system environment variables classpath. Hopefully you know how to do this on your machine. What I like to do on the windows machine is create a batch file that will start it from within a command prompt. I do this because there are times when I need to compile my code using different versions of the Java api. I am enclosing an example of one for J2se1.4.1 and j2ee1.3.1.
    contents of java141.bat
    @ECHO OFF
    ECHO JDK 1.4.1 and J2EE 1.3.1 are current versions
    set HOLD_CP = %CLASSPATH%
    set HOLD_PATH = %PATH%
    set CLASSPATH=.
    set CLASSPATH=%CLASSPATH%;e:\jdk14\jre\lib\rt.jar
    set CLASSPATH=%CLASSPATH%;e:\jdk14\lib\dt.jar
    set CLASSPATH=%CLASSPATH%;e:\jdk14\lib\tools.jar
    set CLASSPATH=%CLASSPATH%;e:\jdk14\lib\htmlconverter.jar
    rem **** J2EE STUFF ****
    set CLASSPATH=%CLASSPATH%;e:\j2ee131\lib\j2ee.jar
    set CLASSPATH=%CLASSPATH%;e:\j2ee131\lib\ejb10deployment.jar
    set CLASSPATH=%CLASSPATH%;%HOLD_CP%
    set PATH=e:\jdk14\bin
    set PATH=%PATH%;"C:\Program Files\TextPad 4"
    set PATH=%PATH%;c:\windows\command
    set PATH=%PATH%;%HOLD_PATH%I hope this helps.
    TJJ

  • Trouble compiling a Servlet using the JSWDK-1.0.1

    I have an old Win95 box on which I had a JDK 1.2 install and I then installed the JSWDK-1.0.1. I have the servlet.jar and jspengine.jar files in the "\lib" directory and have added them to my classpath.
    I created a simple servlet but it does not read any classes from the JSWDK .jar files and throws an error saying class HTTPServlet not found. The first few lines of my servlet look like:
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class TestServlet extends HTTPServlet
    Any idea why the "javac" compiler cant see the class from the proper jar file? I am using JBuilder as my source code editor and it too shows all the servlet related class/package names in red (i.e. doesnt recognize them).
    Regular java apps compile and run fine on this machine.

    Hi,
    It should be definitely a CLASSPATH problem. You can double check the CLASSPATH in command prompt like this
    echo %CLASSPATH%
    If the CLASSPATH is set properly, you should see something like this
    c:\jdk1.2\lib\tools.jar;c:\jswdk-1.0.1\lib\servlet.jar
    Hope this helps.
    Best Luck!
    Senthil Babu J

  • Compiling a Servlet that uses JavaBean

    I have a servlet that will get data from a JavaBean which is created before in a jsp file. While I trying to compile the servlet I am getting this message:
    --------------------Configuration: JDK version 1.3 <Default>--------------------
    Command : "C:\jdk1.3\bin\javac.exe" -d "C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes" C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\MyServlet.java
    Directory : C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes
    C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\TasitKayitGirisi.java:19: cannot resolve symbol
    symbol : class SimpleBean
    location: class MyPackage.SimpleBean
         SimpleBean simpleBean = (SimpleBean) session.getAttribute
    ^
    ("simpleBean");
    C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\MyServlet.java:19: cannot resolve symbol
    symbol : class SimpleBean
    location: class MyPackage.SimpleBean
         SimpleBean simpleBean= (SimpleBean) session.getAttribute("simpleBean");
    ^
    2 errors
    Process completed.
    Where is the problem. SimpleBean is successfully being initializing in my jsp file. But I couldn't compile my servlet that will get data from that bean. Both my servlet and bean are in the same package. I am using JCreator to compile servlets. I think the problem is the compile string that JCreator uses. Can you help me. Thx in advance.

    Looks like an import Problem.
    The Compiler is not able to "see" the SimpleBean Class.
    Take care of the Classpath and your imports.
    Happy Coding. :-)

  • How to compile a servlet

    I am trying to compile a servlet using the import javax.servlet.*;
    import javax.servlet.http.*; packages. But the only thing I keep getting is :
    BasicServlet.java:1: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    BasicServlet.java:2: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    BasicServlet.java:6: cannot resolve symbol
    symbol : class HttpServlet
    location: class BasicServlet
    public class BasicServlet extends HttpServlet
    I have included the servletapi2_1_1-win package from the sun site containing the servlet.jar in my classpath. Still it refuses to compile. Besides does anybody know how to compile using the servlet packages available in Tomcat or j2ee, both of which I have on my machine , but can't figure what to include.
    Please help.
    ^

    have you actually included the servlet.jar file in your classpath or just the directory, as you need to explicity declare jar files in the classpath...
    javac -classpath %CLASSPATH%;C:\[servlet-jar-path]\servlet.jar Servlet.class

  • Problems to compile a servlet

    Hi, i have a problem to compile a servlet, i will try to explain my problem easily...
    i have a JavaBena class int he directory.....C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes......and i have compiled it by DOS commands, everyhting has gone well!
    i have a Servlet class in the same directory where it situated the JavaBean. i compile the Servlet as well as i have done with the Javabean, by DOS commans, including the Tomcat servlet api.
    this is the command which i use to compile the servlet.......javac ServletRegistraUtente.java -classpath "C:\Programmi\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar".....
    but everything i get this error...
    C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes>javac ServletRicercaUtente
    .java -classpath "C:\Programmi\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar"
    ServletRicercaUtente.java:20: cannot find symbol
    symbol : class BeanRicercaUtente
    location: class ServletRicercaUtente
    ^
    ServletRicercaUtente.java:20: cannot find symbol
    symbol : class BeanRicercaUtente
    location: class ServletRicercaUtente
    BeanRicercaUtente m_BeanRicercaUtente = new BeanRicercaUtente();
    ^
    2 errors
    C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes>
    these are the 2 classes....
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    import JavaBean.BeanRicercaUtente;
    public class ServletRicercaUtente extends HttpServlet
         public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws IOException, ServletException
              ServletContext sc;
              RequestDispatcher rd;
              try
                   BeanRicercaUtente m_BeanRicercaUtente = new BeanRicercaUtente();
                   request.setAttribute("m_BeanRicercaUtente", m_BeanRicercaUtente);
                   String codiceFiscale = request.getParameter("codice");
                   m_BeanRicercaUtente.effettuaRicerca(codiceFiscale);
                   sc = getServletContext();
                   rd = sc.getRequestDispatcher("/risposta.jsp");
                   rd.forward(request, response);
              catch(Throwable theException){}
    import java.sql.*;
    public class BeanRicercaUtente
         String nome, cognome, indirizzo, telefono;
         public void effettuaRicerca(String codiceFiscale)
              try
                   Class.forName("com.mysql.jdbc.Driver");
                   String url = "jdbc:mysql://.................";
                   Connection con = DriverManager.getConnection(url);
                   Statement cmd = con.createStatement();
                   String qry = "SELECT ..................";
                   ResultSet res = cmd.executeQuery(qry);
                   while (res.next())
                        cognome = res.getString(1);
                        nome = res.getString(2);
                        indirizzo = res.getString(3);
                        telefono = res.getString(4);
                   res.close();
                   cmd.close();
                   con.close();
              catch (SQLException e)
                   e.printStackTrace();
              catch (ClassNotFoundException e)
                   e.printStackTrace();
    i would be glad to get help about it...! :) thanks!

    i am sorry, but in the first class i have not written "import JavaBean.BeanRicercaUtente;"
    i have only these imports...
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;

  • Problem with Servlet Tutorial

    I am going through the servlet tutorial with a specific end in mind. I found a section that I think relates exactly to what I want to do. I want to have servlet redirect the user to another URL. The following code is given as an example.
    public class Dispatcher extends HttpServlet {     
       public void doGet(HttpServletRequest request,      
          HttpServletResponse response) {     
          request.setAttribute("selectedScreen",     
             request.getServletPath());     
          RequestDispatcher dispatcher = request.     
             getRequestDispatcher("/template.jsp");     
          if (dispatcher != null)     
             dispatcher.forward(request, response);     
       public void doPost(HttpServletRequest request,      
    }The problem is that I can't compile this. There is no HttpServletRequest.getRequestDispatcher(String) method. Am I misssing something here? Am I even on the right track?

    An extract from one of my servlets that redirects to
    another URL is
    this:response.sendRedirect(response.encodeRedirec
    URL("NoLogon"));But it appears you want to
    forward, rather than redirect. There's a difference,
    but I don't exactly know what it is. The forwarding
    example in my servlets book looks like
    this:RequestDispatcher dispatcher =
    getServletContext().getRequestDispatcher(address);
    dispatcher.forward(request, response);
    I tried pasting your first example into my code and got the follwoing error:
    Method encodeDirectURL(java.lang.String) not found in interface javax.servlet.ServletResponse
    It seems like there is still something missing here. When I look at the API I only see four methods for this class.

  • What's the easiest way to compile a servlet?

    What on earth is the easiest way to compile a servlet? I have ant and I know how to use it, but there has to be an easier way. I write my programs in Textpad and it'll only spit out errors when i try to compile:
    C:\projects\WEBDEV\merchandiseServlet.java:2: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    C:\projects\WEBDEV\merchandiseServlet.java:3: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    C:\projects\WEBDEV\merchandiseServlet.java:15: cannot resolve symbol
    symbol : class HttpServlet
    location: class merchandiseServlet
    public class merchandiseServlet extends HttpServlet
    ^
    C:\projects\WEBDEV\merchandiseServlet.java:21: cannot resolve symbol
    symbol : class HttpServletRequest
    location: class merchandiseServlet
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    ^
    C:\projects\WEBDEV\merchandiseServlet.java:21: cannot resolve symbol
    symbol : class HttpServletResponse
    location: class merchandiseServlet
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    ^
    C:\projects\WEBDEV\merchandiseServlet.java:22: cannot resolve symbol
    symbol : class ServletException
    location: class merchandiseServlet
                        throws ServletException, IOException {
    ^
    I have my JAVA_HOME variable set to C:\j2sdk1.4.1_01 and my J2EE_HOME set to C:\j2sdkee1.3.1 and that is exactly where each are installed. How would a person compile a servlet say.. on the command line? It seems there would be an easier way than having to do a build file and all that. Any help would be greatly appreciated. I've written a lot of stuff that works great but for some reason this stuff is giving me fits. thanks in advance

    C:\projects\WEBDEV>javac -classpath "C:\j2sdk1.4.1_01\bin; C:\j2sdkee1.3.1\bin;
    C:\j2sdkee1.3.1\lib\j2ee.jar" merchandiseServlet.java
    merchandiseServlet.java:2: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    merchandiseServlet.java:3: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    I got 7 total errors that time, more than before, all of them dealing with packages in the j2ee. The classpath is 100% correct for the way I installed everything; I have checked it about three hundred times. Could htere be some other small detail I missed?

  • Compiling a servlet in command line

    Hi,
    Can someone show me the command to type in to compile a servlet in command line. I know i have to include the servlet.jar file, but i don't remember the exact command.
    Thanks

    D:\logs>javac
    Usage: javac <options> <source files>
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    -nowarn Generate no warnings
    -verbose Output messages about what the compiler is doing
    -deprecation Output source locations where deprecated APIs are used
    -classpath <path> Specify where to find user class files
    -sourcepath <path> Specify where to find input source files
    -bootclasspath <path> Override location of bootstrap class files
    -extdirs <dirs> Override location of installed extensions
    -d <directory> Specify where to place generated class files
    -encoding <encoding> Specify character encoding used by source files
    -source <release> Provide source compatibility with specified release
    -target <release> Generate class files for specific VM version
    -help Print a synopsis of standard options

  • I can't access able to compile the servlet that access EJB methods

    Hello,
    i have written i servlet (TestServlet.java) to access the ejb(SignOn) method(validateUser(userId,Password)) but i can't compile this servlet.it shows this type error.can anybody help me to do it complete.i have written the ejb & servlet in (d:\ejb\src\demo).
    D:\riazejb\src\demo>javac TestServlet.java
    TestServlet.java:15: cannot find symbol
    symbol : class SignOnHome
    location: class demo.TestServlet
    SignOnHome signOnHome;
    ^
    TestServlet.java:16: cannot find symbol
    symbol : class SignOn
    location: class demo.TestServlet
    SignOn signOn;
    ^
    TestServlet.java:23: cannot find symbol
    symbol : class SignOnHome
    location: class demo.TestServlet
    signOnHome = (SignOnHome)PortableRemoteObject.narrow(objref,SignOnHome.c
    lass);
    My servlet code is
    package demo;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import javax.naming.*;
    import javax.ejb.*;
    import demo.*;
    import javax.rmi.PortableRemoteObject;
    public class TestServlet extends HttpServlet {
    SignOnHome signOnHome;
    SignOn signOn;
    public void init(ServletConfig config) throws ServletException {
    //Look up home interface
    try {
    InitialContext ctx = new InitialContext();
    Object objref = ctx.lookup("demo/SignOn");
    signOnHome = (SignOnHome)PortableRemoteObject.narrow(objref,SignOnHome.class);
    } catch (Exception NamingException) {
    NamingException.printStackTrace();
    public void doGet (HttpServletRequest request,HttpServletResponse response)
    throws ServletException, IOException
    PrintWriter out;
    response.setContentType("text/html");
    String title = "EJB Example";
    out = response.getWriter();
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Hello World Servlet!</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<p align=\"center\"><font size=\"4\" color=\"#000080\">Servlet Calling Session Bean</font></p>");
    try{
    // MyTestSession beanRemote;
    SignOn signOn;
    signOn = (SignOn)signOnHome.create();
    out.println("<p align=\"center\"> Message from Session Bean is: <b>" + signOn.validateUser(student,password) + "</b></p>");
    signOn.remove();
    }catch(Exception CreateException){
    CreateException.printStackTrace();
    out.println("<p align=\"center\"><a href=\"javascript:history.back()\">Go to Home</a></p>");
    out.println("</body>");
    out.println("</html>");
    out.close();
    public void destroy() {
    System.out.println("Destroy");
    Thanks in advance.
    Riaz

    Have you added the EJB client JAR to classpath for compilation?
    java -classpath "%CLASSPATH%;<<EJBCLient JAR path>> *.java

  • How to Compile/Run servlet in Tomcat 4.1

    Hi All,
    iam trying to compile my servlet program in tomcat4.1.. but its showing an error
    in the import statement..
    UN SOLVABLE SYMBOL... but the import ststement is correct...
    can any one help ... is there i have to set any path for compiling/running the servlet...
    Thanks in Advice

    hi thanks for your reply
    i have loaded tomcat4.1 exe -- for windows i am starting the tomcat server by clicking from the start menu..
    i dint set any env variable .. tell me how to set...
    regards
    ijay

Maybe you are looking for