Problem running simple servlet on tomcat 4.0

hi,
i have setup tomcat4.0 on the server and i am trying to run a simple servlet but it is not working. here is what i have done:
1. setting the CATALINA_HOME variable to the directory where tomcat is installed
2. setting the classpath variable to servlet.jar
3. i am putting the .class fille in tomcat-home-directory/webapps/ROOTS/WEB-INF/classes
4. i am giving the url as http://localhost:8080/servlet/HelloServlet.class
but error is given...could you please tell where could i have probably made a mistake
regards
preeti

hi tnguyen1973
now my servlets are running on the server provided they are kept under /examples/WEB-INF/classes. But now i have my own folder at the same level of examples called Lm which also has WEB-INF/classes. but if i put my servlets here it is giving exception.hope u got me. please, tell me where should i make necessary modifications to get the servlets run from my own folder instead of examples
thank u

Similar Messages

  • How to run a servlet in tomcat 5.0.

    Hi all,
    how to run a servlet in tomcat 5.0
    please tell me the entire procedure....(directory structure)
    step by step....

    hi :-)
    http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html
    or
    http://www.google.com.ph/search?hl=en&q=java+servlet+tutorial&btnG=Google+Search&meta=
    regards,

  • How to run a servlet in tomcat

    how i can run a servlet in tomcat?

    how i can run a servlet in tomcat?Don't try to do that yet; in your other thread you have shown that your are
    not capable yet of setting up a proper development environment.
    Take my advice, you can't walk or run yet so start with the basics.
    kind regards,
    Jos

  • How to run a servlet in tomcat 5.5

    Hi,iam new to servlets,please help me regarding running a servlet in tomcat 5.5,
    I just want an example servlet to run first,
    the below is the code for the same :-
    //ExampleServlet.java
    package sig;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ExampleServlet extends HttpServlet {
         public void init(ServletConfig config) throws ServletException{
              super.init(config);
         public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{
              PrintWriter out = res.getWriter();
              out.println("<HTML>");
              out.println("<BODY>");
              out.println("<p>Hello World</p>");
              out.println("</BODY>");
              out.println("</HTML>");
    I have created a new folder named "SignatureServlet" under the "webapps" folder of tomcat and have created a "WEB-1NF" folder under it,
    again i have kept my "ExampleServlet.class" inside the "WEB-1NF->classes" folder and the entries for my servlet in the "web.xml" file are:-
    <servlet>
    <servlet-name>ExampleServlet</servlet-name>
    <servlet-class>ExampleServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ExampleServlet</servlet-name>
    <url-pattern>/ExampleServlet</url-pattern>
    </servlet-mapping>
    still when iam trying to access the servlet using "http://localhost:8080/ExampleServlet/"
    iam getting a HTTP:404 error
    The requested resource () is not available.,
    please help

    You better ask this on a Tomcat forum...
    Timo

  • Problem getting simple servlet to run in tomcat

    i am trying to get a servlet to run that is explained in wrox Professional JSP second edition. i am using tomcat as the book explains.
    1. i have created the ch03/WEB-INF/classes directory within the webapps folder in tomcat.
    2. in the classes folder i created the directory
    com/wrox/projsp/ch03/myfirstwebapp.
    3. in the folder myfirstwebapp i have the compiled file
    MyFirstServlet.class
    4. i made sure the code is exactly as in the book.
    5. it states that if i go to
    http://localhost:8080/ch03/servlet/com.wrox.projsp.ch03.myfirstwebapp.MyFirstServlet i should get the correct output.
    6. the only way i can get this to work is if i create a web.xml
    file and point it to
    com.wrox.projsp.ch03.myfirstwebapp.MyFirstServlet and then in the
    browser i type in
    http://localhost:8080/ch03/com.wrox.projsp.ch03.myfirstwebapp.MyFirstServlet thus leaving out /servlet in the URL
    7. this seems fine but i would like to get it to work how the book shows which is without having to use the web.xml. am i missing something? do i need to set up anything (eg. a context tag for this app)within the server.xml.
    any help would greatly be appreciated,
    gary bushek

    I don't know how the book you're using instructed you to setup the server but my web.xml simply has the following in it:
    <?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>
    </web-app>
    I'm using tomact 3.2 and am able to run my servlets using
    http://localhost/servlet/package_name.servletName
    you might want to checkout www.coreservlets.com for more help on setting up tomcat.

  • Just can't run HELLOWORLD servlet on Tomcat!

    Hi there, I worked with servlets all summer long and now I'm getting back to build one, and I'm totally confused... My problem's there :
    I try to run a simple HelloWorld servlet on Tomcat 4.1, and I get a 404 Error - Not found
    Well, here's the structure of my web application, contained in simpleservlet.war :
    WEB-APP
    -web.xml
    -CLASSES
    -servlet.class
    -LIB
    -servlet.jar
    Here's now the content of the web.xml file :
    <web-app>
         <servlet>
              <servlet-name>serv</servlet-name>
              <servlet-class>servlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>serv</servlet-name>
              <url-pattern>/test</url-pattern>
         </servlet-mapping>
    </web-app>
    AND FINALLY here's how I invoke my servlet, I TRIED :
    http://localhost:1977/servlet/test
    AND ALSO
    http://localhost:1977/test
    AND BANG, I GET "ERROR 404 - NOT FOUND"
    A little help would be appreciated A LOT, well it's not supposed to be a hard problem... and by the way, I'm using port :1977, the problem's not there though.
    regards, Pierre

    Hi,
    First try http://localhost:1977 and see if you are getting Tomcat. As you said, this is not a problem. So, you should get the index.html of the Tomcat. Now, click on the one of the example. From the Address Bar, you will know the path of this example. Try putting your page at that location and then run.
    This should work.
    -- Ashish.

  • Problem Running my servlet

    Hi,
    I use Tomcat 5.5.17 to run servlets. I can run the example servlets that come with Tomcat successfully. I have configured the java_home and class path variables. When I create a new servlet in the webapps/servlets-examples folder, I can run it.
    However, when I try creating a new folder under webapps (named trial) and when I try to run my servlet from there I get the 404 Servlet not found error.
    The steps I followed are:
    1.Created a new folder trial under C:\apache-tomcat 5.5.17\webapps
    2.Created the WEB_INF folder under trial and then the classes folder under it.
    3. Put my servlet HelloServlet.class under the classes folder.
    4.Put WEB.XML under the C:\apache-tomcat 5.5.17\webapps\trial\WEB_INF folder and made the following entry
    <servlet>
    <servlet-name>HelloServlet</servlet-name>
    <servlet-class>HelloServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloServlet</servlet-name>
    <url-pattern>/HelloServlet</url-pattern>
    </servlet-mapping>
    5. I tried to access my servlet using the following URL:
    http://localhost:8080/trial/HelloServlet
    and that gives the 404 error.
    Are there any additional steps when we are running a servlet a folder we create?
    I searched the internet and found something about setting the context path but I could not understand how to do it for Tomcat 5.5.17 as the documents I found on the net were for older versions.
    I would be grateful if someone could help me out. Thanks in advance!
    Aniticipating your help!
    Thanks and Regards,
    Asana

    Hi.. You can check your application context path through Tomcat Manager application.
    URL is :
    http://localhost:8080/manager/list
    or
    http://localhost:8080/manager/html/list

  • Problem compiling simple servlet

    I am trying to compile a very simple servlet.
    When I do, I get the following error message:
    Package javax.servlet does not exist
    I am using the Java 2 SDK, Standard Edition Version 1.3.1.
    I have downloaded the servlet api (zip file servletapi2_1_1win.zip)
    from Sun's site. I unzipped these files in my lib directory; there are two folders,
    one called api and the other called src. Api and Src directories have their own
    sub-folders, javax/servlet/http etc.
    I am using W2K ; I had to create a CLASSPATH system variable in the environment
    variables section of control panel since there was none defined.
    I added the following line:
    C:\jdk1.3.1_01\lib\api\javax\servlet;C:\jdk1.3.1_01\lib\api\javax\servlet\http;
    I also did this for the PATH statement..
    My servlet looks like this:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class howdy extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    out.println("<HTML>");
    out.println("<HEAD><TITLE>Hello World </TITLE></HEAD>");
    out.println("<BODY>");
    out.println("<BIG>Hello World </BIG>");
    out.println("</BODY></HTML>");

    Thanks. I was able to figure it out by specifying the
    full classpath
    at the command line, like this:
    C:> javac -classpath
    C:\jdk1.3.1_01\lib\servletapi2_1_1-win.zip\MyServlet.ja
    a
    Apparantly the system doesn't acknowledge the
    environmental variable that
    I created in the control panel; also I have no
    autoexec.bat file...so it
    looks like I have to write out the full path whenever
    I need to compile
    something. Kind of bothersome, but at least it
    works.
    You shouldn't have to do this. What operating system are you using?
    If you are using win2000, winNT or winxp, you should set the classpath in your system environment varialbes. You can also make a config.bat file and put everything in there. Then just run this config.bat file to set up your environment once for every session.
    Here's a file that I have set up on one of our NT machines. I just double click the icon for this file on my shortcut, and it gives me the window where I can compile my java programs.
    Hope this helps.
    Kamran
    =========== File SetJava.bat ============
    set PATH=%PATH%;m:\jdk1.3\bin
    set CLASSPATH=m:\jdk1.3\jre\lib;m:\jdk1.3\jaxp-1.1\jaxp.jar;m:\jdk1.3\jaxp-1.1\crimson.jar;m:\jdk1.3\jaxp-1.1\xalan.jar;.
    cd cis235
    %SystemRoot%\system32\cmd.exe

  • Cannot run a servlet using Tomcat. Urgent

    I have a webapplication which uses some jsp's and servlets. The jsp pages work fine when I use
    http://hostname:8080/MyWebapp/Filename.jsp
    However, when I developed a java servlet and put the class file in WEB-INF/classes directory of my web application and tried to access it.
    I got a resource not found error.
    The strange thing is that when I put the file in the web-inf/classes folder of examples webapplication (which comes with Tomcat) I am able to run the servlet using
    http://hostname:8080/examples/servlet/Class file
    I am not sure what is wrong.
    Can someone help me.
    Thanks in advance
    Vamsi.

    It's predictable. The Servlet and JSP specifications mandate that you cannot directly access resources under WEB-INF directory. You have to set up servlet mapping configuration in your web.xml to specify how to access the resources, both Servlet and JSP, there.
    When you copied your files in a demo webapp of Tomcat, the web.xml of the demo app already set up the mapping like following for you. So you could use http://hostname:8080/examples/servlet/Class to visit the servlet.
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
    The default setting since Tomcat 4.1 turned off servlet invoker in web.xml under conf directory. You can uncomment the above lines in this file to turn it on. Then you are able to visit your servlet without <servlet-mapping> configured using the following syntax,
    http://hostname:8080/<your_app_name>/servlet/<your_servlet_name>

  • How to run a servlet in Tomcat 5.0 server

    HI Everybody,
    I want to know how to run the servlet file on my tomcat 5.0 server. that is where to place a class file and deployment details.
    Thanks In ADVANCE

    Sourav_cs wrote:
    I am a biginner to start servlet i get confusion to configure servlet in tomcat 5 where it should be saved in tomcat directory and how to execute that as first timeHi,
    goto
    tomcat 5.0\webappsnow create a folder here. this is your webapplication project name. Let's suppose it as "TestApp"
    inside this create directories as follows :
    TestApp
            |
            |-----JSP/htmls( if you have any )
            |
            |-----WEB-INF(File Folder)
                       |
                       |-----web.xml
                       |-----lib ( Directory. place all the .jar files which are required for this project(if any) )
                       |-----classes ( .class files. )[all of your java code should be placed here.](servlets / beans/ pojo )this is the general Directory structure of a web application. now you've to place the compiled .class file of your servlet in the "TestApp\WEB-INF\classes" directory. make sure that you've configured the servlet in Deploment Desctiptor, i.e, web.xml.
    now start the server and type the url like : "http://localhost:8080/TestApp/TestServlet"
    the port no. 8080 is the default port no. of tomcat. you have to give your port no. if u've modified it. and TestServlet is the <url-pattern> of your servlet.
    go through some tutorials .. then you can easily know that
    Diablo

  • Trying to run simple servlet - error

              I am the first time user of Beas Weblogic & I am trying to run simple example
              servlets from Weblogic Console. However, when I try to LoadServlets, I get an
              error 'Property Change Error for Property "Load"; Unable to load servlet'
              Is there anything I am missing? I'd appreciate any help.
              Thx.
              Ravi
              

    Hi,
    I have found out the cause. im pointing to the wrong classpath. it should be class12.zip instead of class111.zip, something i copied from my server running oracle8i.

  • How can I run a servlet with tomcat

    I'm a new learner in servlet,I recently write a servlet program,when I compile it,the compiler throws the error
    "package javax.servlet.http does not exist",I have put the servlet.jar(which exist in d:\tomcat\bin directory) file into the classpath directory;my servlet source files are in D:\tomcat\webapps\mywork\web-inf\classes\com\stardeveloper\servlets;
    "com.stardeveloper.servlets" is the package for my servlet source files,so I have write the sentence "package com.stardeveloper.servlets;" in my servlet source file.
    I don't know how to resolve this problem.can you give me a help?

    servlet.jar doesn't exist in the folder you mentioned, but rather, in C:\tomcat40\common\lib, so this should be included in your classpath, the other thing you should care about is how you compiled your servlets, so that the package statement match the hirarchy of the file.
    regards

  • Having problem running a servlet program in Tomcat5.5

    Hi,
    I wrote a sample servlet, HelloWorld.java and I compiled it and put the .class file in the WEB-INF\Classes directory in the Tomcat directory. Now when I do this,
    http://localhost:8080/ it's working fine but when I do this, http://localhost:8080/servlet/HelloWorld I am getting an error message "*HTTP Status 404"*.
    I have done no changes to web.xml and server.xml. Should I be doing anything?
    My HelloWorld.Java file is as below.
    package Users.Ravi.Desktop.CurrentProject.Servlets;
    import java.io.*; 
    import javax.servlet.*;  
    import javax.servlet.http.*;
    public class HelloWorld extends HttpServlet {
    public void doGet(HttpServletRequest request,
                        HttpServletResponse response)
          throws ServletException, IOException { 
        PrintWriter out = response.getWriter();
        out.println("Hello World");
    }Thanks.

    Ah, I see the problem now. You need to put servlet class as
    <code class="jive-code jive-java">Users.Ravi.Desktop.CurrentProject.Servlets.HelloWorld</code>
    <code class="jive-code jive-java">So, your web.xml will have</code>
    <servlet>
         <servlet-name>HelloWorld</servlet-name>
         <servlet-class></code><code class="jive-code jive-java">Users.Ravi.Desktop.CurrentProject.Servlets.HelloWorld</code><code class="jive-code jive-java"></servlet-class>
    </servlet>{code}

  • Problem in executing servlets under tomcat 4.1

    Dear Group,
    I am using Tomcat 4.1 and have the following directory structure:
    1.     C:\Tomcat 4.1\webapps\testapp
    ----It is my root directory and I have my html file called
    sample.html
    2.     C:\Tomcat 4.1\webapps\testapp\WEB-INF------web.xml is here
    3.     C:\Tomcat 4.1\webapps\testapp\classes\TestServlet.class
    -------here I have the servlet, no package---only one servlet
    My[b] web.xml has entry for:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!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>
        <servlet>
            <servlet-name>TestServlet</servlet-name>
            <servlet-class>TestServlet</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>TestServlet</servlet-name>
            <url-pattern>/TestServlet</url-pattern>
        </servlet-mapping>
    </web-app>My[b] sample.html contains:
    <HTML>
    <BODY>
    <form method="post" action="http://localhost:8080/testapp/TestServlet">
    <input type=submit value="showServlet">
    <h2>
    <font color="green">First try on Serlvet</font>
    </h2>
    </form>
    </BODY>
    </HTML>Here is what I have done:
    1.     Started the Tomcat server
    2.     In the IE browser, I typed http://localhost:8080/testapp/sample.html
    -------- - the file shown correctly and I clicked the showServlet button.
    3.     I got the follow error �HTTP Status 404 - /testapp/TestServlet" the
    requested resource not availble
    4.     when I clicked the showServelt button the control goes to another page
    (as it should go to execute the servlet) .
    The URL is �http://localhost:8080/testapp/TestServlet�
    Please enlighten me where I went wrong?

    Hello all,
    Thank you for answering the question now the servlet gets executed.
    I here posts the steps i carried out to execute the
    servlet. If anyone have different idea pls post. Im
    pasting here the steps also attaching one.
    Steps to create your directory and work in Tomcat 4.1
    1.     Create your directory in Tomcat�s webapps Directory.
    -----If your tomcat is in d:\ the your directory may look
    ----- D:\tomcat\webapps\<your directory>
         ------E.g. �d:\tomcat\webapps\test�
    2.     In the test directory you can your html files directly or you can create a
    directory to hold html files.
         --------E.g. �d:\tomcat\webapps\test\first.html (OR)
    -------E.g. �d:\tomcat\webapps\test\html-files\first.html�
    3.     Create a folder called WEB-INF inside test
    -------E.g. �d:\tomcat\webapps\test\WEB-INF
    ------ Under the WEB-INF folder put your web.xml file
    4.     Create another folder named classes under the same test
    ----- E.g. �d:\tomcat\webapps\test\classes
    ----- Here you need to place your servlet classes
    ----- E.g. �d:\tomcat\webapps\test\classes\testServlet.class
    5.     Start any browser that are java enabled
    6.     Type �http://<machine name (or) IP add.>:8080/<your folder
    name>/<html file>�
    ----     E.g. http://localhost:8080/test/ html-files/first.html
    -----E.g.http://127.0.0.1:8080/test/html-files/first.html
    7.     Click the component (button, label�) to enable servlet
    8.     That�s all! Now you should get your servlet executed.
    Files:
    1.     web.xml
    <!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>
      <servlet>
        <servlet-name>testServlet</servlet-name>
        <servlet-class>testServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>testServlet</servlet-name>
        <url-pattern>/testServlet/*</url-pattern>
      </servlet-mapping>
    </web-app>
    2. first.html
    <html>
    <body>
    <form method="POST"
    action="http://localhost:8080/test/testServlet">
    <input type=submit value=click></input>
    </form>
    </body>
    </html>
    3. testServlet.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class testServlet extends HttpServlet
         public void doPost(HttpServletRequest req,
    HttpServletResponse res)throws      ServletException,
    IOException
              PrintWriter out = res.getWriter();
              out.println("<html>");
              out.println("<body>");
              out.println("<h1>Hello! </h1>");
              out.println("</body>"+"</html>");
    }I have put my first.html inside the folder
    �d:\tomcat\webapps\test\html-files\� and testServlet
    is under �d:\tomcat\webapps\test\WEB-INF\classes\� folder.

  • Problem Running ADF page in Tomcat 6 (AdfPage is not defined error)

    I'm using JDEV 11.1.1.5
    Tomcat 6.0.24
    I have the JSPX page below deployed on Tomcat.
    At runtime I get an error: AdfPage is not defined
    On this line of code:
    var passwordTextField = AdfPage.PAGE.findComponentByAbsoluteId('password');
    Any suggestion on why it does not recognize AdfPage in the javascript function?
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
              xmlns:c="http://java.sun.com/jsp/jstl/core"
              xmlns:trh="http://myfaces.apache.org/trinidad/html">
      <c:set var="bundle"
             value="#{adfBundle['oracle.apps.grc.ui.landing.GRCLandingPFBundle']}"/>
      <jsp:directive.page contentType="text/html;charset=UTF-8"/>
      <f:view>
      <af:document id="loginPage">
            <af:group>
            <af:resource type="javascript" source="/oracle.apps.grc.ui.cryptoclient.CryptoClient.nocache.js"/>          
            <af:resource type="javascript">
                function login(event) {
                    try {
                        var grcCrypto = new window.grc.Crypto();
                        var passwordTextField = AdfPage.PAGE.findComponentByAbsoluteId('password');
                        passwordTextField.setValue(grcCrypto.encrypt(passwordTextField.getValue()));
                        var submitLoginButton = AdfPage.PAGE.findComponentByAbsoluteId('submit_login');
                  AdfActionEvent.queue(submitLoginButton, submitLoginButton.getPartialSubmit());
                        event.cancel();
                    catch (e) {
                        alert(e.message);
            </af:resource>
            </af:group>

    Hi.
    as Raphael says, check your libraries.
    I think that adfpage is in adf-richclient-api-11.jar, check if this library is in your %CATALINA_HOME%/lib folder.
    Anyway I will inform you that Tomcat is not a certificate server,http://www.oracle.com/technetwork/developer-tools/jdev/index-091111.html#Application_Servers

Maybe you are looking for

  • Installing Adobe Photoshop - disk full when it isn't?

    Here it is, I am running windows 7 ultimate from a 40gb ssd card (which is almost full) however I save all of my programs, files, pictures etc. onto my secondary 3TB drive which is almost empty. Trying to install adobe photoshop elements 12 - says th

  • Changes are not visible

    I have to change an existing application from another developer. The application is developed on DEV and is running there. I can edit everything in the apex but nothing is visible on DEV. Only new created items are visible on DEV, but only for me. Ha

  • Discoverer folders security

    Hi, Anyone any idea if there is any way (query) to figure out the responsibility name or id through which we log into discoverer at that moment? Thanks in advance --Kumar                                                                                

  • Task flow diagram

    I need a solution on the following topic : User will draw a task flow diagram in the screen .Flow will be first with Start then task 1 then task 2 .task 2 can have one child task 3 .task 2 will have another child task4.task 3 will have child task5 .t

  • Changes to name in SU01

    We are trying to figure out a way to find out if there are changes logged when a user's first or last name are changed in the SU01 record. We have a user whose name was changed in SU01, but have no idea of how to find who changed it or when. Any info