Parameters in a mapped servlet in Tomcat

I am using Tomcat 4.0.2/JDK 1.3.1 running on Solaris. I have the following servlet called foo.Bar, named FooBar in the web.xml file for my webapp.
<servlet>
<servlet-name>FooBar</servlet-name>
<display-name>FooBar</display-name>
<description></description>
<servlet-class>foo.Bar</servlet-class.
</servlet>
I can access this servlet from the following url:
http://localhost/webappname/servlet/FooBar ,
also:
http://localhost/webappname/servlet/FooBar/param1/param2
works as well.
But, if I put a servlet-mapping in the web.xml file:
<servlet-mapping>
<servlet-name>FooBar</servlet-name>
<url-pattern>/foo</url-pattern>
</servlet-mapping>
The following URL does not work:
http://localhost/webappname/foo/param1/param2.
Is this a problem in Tomcat? Or is there another section of the web.xml file to tell the url parser to stop at the end of the servlet mapping?
Thanks.
C

This is not a bug. The servlet spec says
"In the web application deployment descriptor, the following syntax is used to define
mappings:
� A string beginning with a �/� character and ending with a �/*� postfix is used
for path mapping.
� A string beginning with a �*.� prefix is used as an extension mapping.
� A string containing only the �/� character indicates the "default" servlet of the
application. In this case the servlet path is the request URI minus the context
path and the path info is null.
� All other strings are used for exact matches only."
Sounds like you need a pattern of /foo/*

Similar Messages

  • Servlet mapping with Apache + Tomcat

    I'm trying to set up my servlet with apache + Tomcat(3.2.3), and i'm using mod_jk as the Tomcat-Apache plug-in.
    The HelloWorld servlet that comes with the examples app worked fine at: http://localhost/examples/servlet/HelloWorldExample,
    but how do I change the configurations, so that it can be invoked at:
    http://localhost/examples/HelloWorldExample ?
    It appears to me that '/servlet/' is the default prefix for Tomcat's RequestInterceptor, there is no way to get around that.
    Any insights will be greatly appreciated, thanks!
    Elaine

    hi
    Try this:
    add below code in web.xml file in examples/WEB-INF
    F directory
    <servlet-mapping>
    <servlet-name>
    HelloWorldExample
    </servlet-name>
    <url-pattern>
    /HelloWorldExample
    </url-pattern>
    </servlet-mapping>
    Thanks for the reply, the web.xml is already set up this way, in fact, I'm able to invoke the servlet through tomcat(running on port 8080): http://localhost:8080/examples/HelloWorldExample,
    tomcat reads the web.xml without any problems.
    The problem comes from Apache(port 80), http://localhost:80/examples/HelloWorldExample wouldn't work, only http://localhost:80/examples/servlet/HelloWorldExample works.
    It appears to me that when requests are relayed from Apache to tomcat, you need to tell tomcat that you intend to invoke a servlet by prefixing '/servlet/', if you look in the server.xml, it has
    <RequestInterceptor
    className="org.apache.tomcat.request.InvokerInterceptor"
    debug="0" prefix="/servlet/" />
    I've tried to change this to something else, it didn't seem to make any difference.

  • Unable to set root/main/default servlet in Tomcat 5.5

    I'm on a shared hosting account with Tomcat 5.5 and cannot figure out why I can't set the default servlet. I want all incoming requests regardless of the relative path, to be handled by the Redirect servlet. There is only one servlet in the whole project.
    Some examples
    http://www.mydomain.com -> Redirect servlet (not working)
    http://www.mydomain.com/ -> Redirect servlet (not working)
    http://www.mydomain.com/a -> Redirect servlet
    http://www.mydomain.com/blaldjflajdd -> Redirect servlet
    With the below web.xml file, the last two above works just fine, but the first two gives a 403 error. What gives, I followed the Tomcat documentation to the teeth... It seems to work on my development server, but not on the shared hosting. Is this a setting anyone would block? Any help would be much appreciated.
    The full web.xml setting below:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
         <display-name>Redirect</display-name>
         <servlet>
              <display-name>Redirect</display-name>
              <servlet-name>Redirect</servlet-name>
              <servlet-class>com.somedomain.Redirect</servlet-class>
              <init-param>
                   <param-name>host</param-name>
                   <param-value>www.myotherdomain</param-value>
              </init-param>
              <init-param>
                   <param-name>redirect-type</param-name>
                   <param-value>301</param-value>
              </init-param>
         </servlet>
         <servlet-mapping>
              <servlet-name>Redirect</servlet-name>
              <url-pattern>/</url-pattern>
         </servlet-mapping>
    </web-app>I tried adding other mappings as well that didn't work, such as :
         <servlet-mapping>
              <servlet-name>Redirect</servlet-name>
              <url-pattern>/*</url-pattern>
         </servlet-mapping>What would happen if I try an empty url-pattern?
         <servlet-mapping>
              <servlet-name>Redirect</servlet-name>
              <url-pattern></url-pattern>
         </servlet-mapping>Any help would be much appreciated. I tried workarounds, by using an index.jsp file to supplement, but that isn't working quite right either. I prefer to have it setup properly though.... Please Help!!!

    tomcat does not compile servlets, only JSP's will be translated and compiled on the fly. You need to compile them yourself, possibly using ANT or an IDE like NetBeans or Eclipse to make it easier to deploy the changes.

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

  • Error 404 invoking servlet in tomcat

    OK Im new in this and I have searched the forums and do most of the answers but I cant make my servlet to work. So here is how I have my structure
    MEDEX \ WEB-INF -> all JSP files
    MEDEX \ WEB-INF \ classes -> all CLASS files
    MEDEX \ WEB-INF \ servlet -> SERVLET CLASS FILE
    I have a page called index.jsp that invokes the servlet by a form like this:
    <form name="form1" method="post" action="http:\\localhost:80\Medex\WEB-INF\servlet">
    this is what I have in my web.xml
    <display-name>Servlet SvMedex</display-name>
    <servlet>
    <servlet-name>SvMedex</servlet-name>
    <servlet-class>SvMedex</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>SvMedex</servlet-name>
    <url-pattern>http:\\localhost:80\Medex\WEB-INF\servlet</url-pattern>
    </servlet-mapping>
    <-- <resource-ref>
    <res-ref-name>http:\\localhost:80\Medex\WEB-INF\bd</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>-->
    </web-app>
    I dont have a server.xml since I edited the server.xml in tomcat/conf to evoke anonimous servlets... that will be while I test
    PLease IM DESPERATE ! any help is really appreciated.

    <url-pattern>http:\\localhost:80\Medex\WEB-INF\servle
    t</url-pattern>URL patterns are specified relative to the webapp. If you use a url-pattern of /SvMedex, your servlet will be available at http://localhost:80/Medex/SvMedex

  • How to Run servlet in Tomcat 5.5.9

    hi
    How to run servlet in tomcat 5.5.9?how to set context path in server.xml of conf folder in tomcat since there is no context tag in server.xml.
    Jiten

    Hi ! I have a similar problem, well, it's along the same line ...
    I'm using NetBeans 4.1, and i've coded a servlet. Using NetBeans to launch my servlet (with the bundled Tomcat 5.5.7) works fine, however i need to deploy my application unto a Tomcat 5.5.9 server.
    Thus, i copied the WAR file generated by NetBeans into the Tomcat 5.5.9 webapps directory, and Tomcat expands it.
    Problem is when i run my JSP pages with the form tags, they do not work on the Tomcat 5.5.9 environment. Anyone knows why?
    (These work on the NetBeans Tomcat bundle 5.5.7)
    My form action :
    <form name="index" method="get" action="PageServlet">
    My web.xml :
    <servlet>
    <servlet-name>PageServlet</servlet-name>
    <servlet-class>application.PageServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>PageServlet</servlet-name>
    <url-pattern>/PageServlet</url-pattern>
    </servlet-mapping>
    I'm really stumbed on why it doesn't work in Tomcat 5.5.9, any help is greatly appreciated, thanks in advance ^_^

  • Running servlet in tomcat 4.1.18

    Hi,
    I am new to servlet and am having trouble running a simple servlet on tomcat 4.1.18. I keep getting an Error 404 resource not found. will someone show me how to run servlet on tomcat?Please.
    Thanks

    To start, make sure you have specified the servlet and mapping in your application's WEB-INF/web.xml file.
    <!-- for example -->
    <servlet>
        <servlet-name>yourServletName</servlet-name>
        <servlet-class>path.to.Servlet</servlet-class>
    </sevlet>
    <servlet-mapping>
        <servlet-name>yourServletName</servlet-name>
        <url-pattern>/servlet/yourServletName</url-pattern>
    </servlet-mapping>

  • How to configure applet/servlet in Tomcat?

    I'm building a web application which is going to be deployed in Tomcat. I have an applet(called MYAPPLET here) which "calls" a servlet(called MYSERVLET here). I cannot figure out how to configure the whole thing.
    /test is my docbase. In /test I made a directory "applet classes" and a directory "servlet". The applet tag I use in the HTML file looks like this:
    <applet
    code="MYAPPLET.class"
    codebase="http://localhost:8080/test/applet classes/"
    <!-- Tell the applet where its peer is located -->
    <param
    name="servlet"
    value="http://localhost:8080/test/servlet/MYSERVLET" />
    </applet>
    Now, when opening the page, the applet can be found but Tomcat gives an error 404 saying that it can not find the servlet. On the other hand, If I make an entry in my web.xml (with url mapping
    <url-pattern>/test </url-pattern> or <url-pattern>/test/servlet </url-pattern>, depending on where I put MYSERVLET)
    for the servlet mentioned above and I put the MYSERVLET in either the WEB-INF/classes directory or in /test/servlet Tomcat gives an error 403. It refuses to connect to the servlet!
    Please can anyone help me. THanx in advance
    debeumers

    You are configuring Tomcat and if you have further questions then post new questions in the forum "Java Servlet Technology".
    Given that your servlet url is "localhost:8080/test/servlet/MyServlet"
    This assumes -
    1) You have created a web application called "test". You have a directory called "test" under- $CATALINA_HOME/webapps
    2) Your html files, jsp files, and subdirectory "applet-classes" (Note - do Not use spaces when naming directories) exist in this top level directory of your web app. If you choose to place your applet classes in this subdir then the codebase can be "applet-classes" - omitting the "/" means this directory is located relative to the current directory of the html file. (No jar files? No archive param then..)
    3) You have a class file called "MyServlet" located - $CATALINA_HOME/webapps/test/WEB-INF/classes
    Some versions of Tomcat require you to uncomment out the area of the Mapping for the Invoker Servlet element in $CAT_HOME/conf/web.xml.
    <servlet-name>invoker</servlet-name>
    <url-mapping>/servlet/*</url-mapping>
    Once this is done, you need not create a directory called "servlet" anywhere in your structure. It is the url mapping.
    You will want to apply url-patterns and mappings to your application specific web.xml (This is located in - $C_H/webapps/test/WEB-INF) when it comes time to deploy the app, but that is not required for testing and development. You need not make changes to the app specific web.xml at this time just to get the servlet to run.
    And finally I suggest you read a book on this subject...

  • Run servlet in tomcat 4.1

    Hi ,
    could someone please help me.
    Iam trying to run servlet in tomcat4.1 but in vain.
    please help

    hi
    If you want run a servlet in tomcat4.1,First write one html file,and servlet file.
    finally you need to write web.xml.this file will be placed in web-inf folder.
    You need to write this tags to run a servlet in tomcat 4.1
    <servlet>
    <servlet-name> name of the servlet</servlet-name>
    <servlet-class>class name of the servlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>name of the servlet</servlet-name>
    <url-pattern>/the ref name which u want call servlet</url-pattern>
    <servlet-mapping>
    Here the servlet name sholud be same .
    The url pattern name must match with the action attribute value in html.
    now you place your html file in root folder.
    place your servlet class file in classes folder.
    start ur browser type this http://localhost:8080/htmlfilename.

  • Deploying a servlet in tomcat 5.0

    I install tomcat 5.0 in my pc
    I can run HelloWorldExample in browser using the following URL:
    http://localhost:8080/servlets-examples/servlet/HelloWorldExample
    I copy the HelloWorldExample.class into folder :
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes
    I also change the web.xml (path -- C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF)to include the following:
    <servlet>
    <servlet-name>org.apache.jsp.index_jsp</servlet-name>
    <servlet-class>org.apache.jsp.index_jsp</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>HelloWorldExample</servlet-name>
    <servlet-class>HelloWorldExample</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>org.apache.jsp.index_jsp</servlet-name>
    <url-pattern>/index.jsp</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>HelloWorldExample</servlet-name>
    <url-pattern>/HelloWorldExample</url-pattern>
    </servlet-mapping>
    but when I type http://localhost:8080/servlet/HelloWorldExample I go an error 404 The requested resource/servlet/HelloWorldExample) is not available.
    I set the JAVA_HOME to j2sdk folder C:\j2sdk1.4.2_04\
    Am I missing sth in classpath?
    And in tomcat 5.0, it is a must to specify all servlet in web.xml?
    Is there any way I just copy the class into the folder and no need to specify the name in web.xml?
    Thank you in advance!

    Hi there,
    actually I can run the example servlet by:
    http://localhost:8080/servlets-examples/servlet/HelloWorldExample
    today I change the web.xml in conf folder, I enable the following lines which are originally remarked:
    (original line 90 to 102)
    <servlet>
    <servlet-name>invoker</servlet-name>
    <servlet-class>
    org.apache.catalina.servlets.InvokerServlet
    </servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>0</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
    </servlet>
    (original line 319 to 324)
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
    then I have the following error when I type:
    HTTP Status 500
    java.util.MissingResourceException: Can't find bundle for base name LocalStrings, locale zh_TW
         java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
         java.util.ResourceBundle.getBundleImpl(Unknown Source)
         java.util.ResourceBundle.getBundle(Unknown Source)
         HelloWorldExample.doGet(HelloWorldExample.java:39)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:419)
         org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:133)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    what should I do?
    Thank you!

  • Newbie question about loading servlets on tomcat

    I have what is probably a very basic question about loading simple servlets on to tomcat to test its installation. I have followed instructions from numerous tutorials to the letter but still I can't get it to work.
    I have installed tomcat on win2k in c:\tomcat. I set up the jdk, environment vars (JAVA_HOME, CATALINA_HOME, TOMCAT_HOME) which all point at the correct dirs. I can compile a servlet without errors. I can also place a test jsp and html file into the root directory and they both work fine.
    However, now I am trying a test servlet and no matter what I do it gives me a 404. I have a servlet class file called "HelloServlet.class" which I placed into the %install_dir%\webapps\ROOT\WEB-INF\classes directory. I try to reference it using this url:
    http://localhost/servlet/HelloServlet
    Tomcat is configured to use port 80 and has been restarted after adding the servlet class file. Does anyone have a clue why this is not working for me?
    Many thanks
    Marc

    You have to add in the web.xml file that it is in the WEB-INF dir, the information about your servlet. An example:
    <web-app>
    <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>
    </web-app>

  • Servlets and Tomcat/Apache

    Okay,
    Tomcat 4.1 running with Apache.
    Installed mod_jk, piece of cake.
    JSPs run through Apache like a dream.
    Tomcat examples ( jsp and servlets) run through Apache perfectly ( that is no :8080 business).
    My JSP's run through Apache no problem. Works great.
    My SERVLETS WILL NOT RUN THROUGH APACHE FOR ANYTHING.
    My context looks like this in server.xml:
    <Context path="/nuweb" docBase="/home/shared/nuweb" debug="0"
    reloadable="true" crossContext="true">
    <Logger className="org.apache.catalina.logger.FileLogger"
    prefix="nuweb" suffix=".log"
    timestamp="true"/>
    </Context>
    Note: that I am not under <TOMCAT_HOME>/webapps.
    The reason is that I will, in production not be the Unix admin on the server. I will only have priviledges within my directory. I will not be able to drop war files in the webapps directory. I will not be able
    to start and stop tomcat or apache ( there are 100 diffrent apache contexts on that machine and someday many of them will be going through tomcat for jsp and servlet support).
    My servlets will only run if I put :8080/nuweb/servlet/HelloServlet in the URL. Take off the 8080 and I get Page not found. Not the tomcat 404 page, the Browswer 404 errror.
    Here is my web.xml which lives in the WEB-INF directory of of /home/shared/nuweb
    <?xml version="1.0" encoding="UTF-8"?>
    <!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>HelloServlet</servlet-name>
    <servlet-class>org.nu.servlet.HelloServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloServlet</servlet-name>
    <url-pattern>/hello</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
    </web-app>
    In devlopment I am on a system that is very close to what the production server will look like ( Tomcat 4.1 same version of Apache, same Unix ). In development I can restart all the servers edit server.xml etc. On the production I would have to schedule that stuff. I want to be able to compile classes and drop them in the WEB-INF/classes... directory and have them run. Is that too much to ask?

    Hi,
    I am also facing same error.
    I am not able to view my servlets via apache web server.
    ie when i do "http://localhost/enlighta/logon"
    I get http 404 page not found error
    but when I do http://localhost:8080/enlighta/logon
    all works fine
    I am using apache 2 and tomcat 4.5
    This is I have done:
    1.I have http server running on port 80
    2. appserver on port 8080
    3. I have a war file enlighta.war deployed on webserevr
    4. The static content like images and html page I have moved to webserver
    5. The servlet context of the app on the app server is /enlighta
    6. In the web.xml I have defined all the servlet maping.
    the port 8009 has the connecter is running/listening.
    the configuration
    sever.xml on tomcat
    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009"
    enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
    <Host name="localhost" appBase="webapps"
    unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">
    httpd.conf on apache
    # Load mod_jk
    LoadModule jk_module modules/mod_jk.so
    # Configure mod_jk
    JkWorkersFile conf/workers.properties
    JkLogFile logs/mod_jk.log
    JkLogLevel info
    # First Virtual Host.
    <VirtualHost 192.168.1.2:8080>
    ServerAdmin [email protected]
    DocumentRoot /enlighta/
    ServerName localhost
    ErrorLog logs/enlighta_error_log
    TransferLog logs/enlighta_access_log
    JkMount /enlighta/* ajp13
    </VirtualHost>
    workers.properties
    worker.list=ajp13
    # Defining a worker named ajp13w and of type ajp13
    # Note that the name and the type do not have to match.
    worker.ajp13.type=ajp13
    worker.ajp13.host=localhost
    worker.ajp13.port=8009
    Now I feel I am doing something wrong on defining virtual host.
    Or may be something else is wrong.
    I have gone thru the previous thread but I dont have mod_jk.conf file.
    Please help!!!
    Thanks
    Sachin

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

  • Getting error 404 when iam running a simple login servlet in tomcat

    hi
    this is my Login.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class Login extends HttpServlet
         public void doPost(HttpServletRequest rq, HttpServletResponse rs)
              String username =rq.getParameter("username");
              String password =rq.getParameter("password");
    try{
              rs.setContentType("text/html");
              PrintWriter out=rs.getWriter();
              out.println("<html><body>");
              out.println("thank u, " + username + "you r logged sucessfully");
              out.println("</body></html>");
              out.close();
              }catch(Exception e){
                   e.printStackTrace();
    i have saved in the form ofC:\Program Files\apache-tomcat-4.1\webapps\sravan\WEB-INF\classes\Login.class
    where sravan is my folder
    step 2: Login.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>login page</title></head>
    <body>
    <h1> WELCOME TO THE SERVLET HOME PAGE</h1>
    ENTER UR USERNAME AND PASSWORD
    <form action="/sravan/Login" method="Post">
         username<input type="text" name="username" >
         password<input type="password" name="password" >
         <input type="submit" value="submit"></form>
         </body>
    </html>
    i have saved in the form C:\Program Files\apache-tomcat-4.1\webapps\sravan\Login.html
    step3:
    my web.xml
    <?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>
    <display-name>beginning j2ee</display-name>
    <servlet>
    <servlet-name>Login</servlet-name>
    <servlet-class>Login</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Login</servlet-name>
    <url-pattern>Login</url-pattern>
    </servlet-mapping>
    </web-app>
    i have saved in C:\Program Files\apache-tomcat-4.1\webapps\sravan\WEB-INF\web.xml
    step4:
    here is my server.xml
    <Context path="/sravan" docBase="sravan" debug="0" reloadable="true" privileged="true"/>
    saved in C:\Program Files\apache-tomcat-4.1\webapps\sravan\WEB-INF\server.xml
    everything is fine....program is compiled ...but when iam running the servlet in tomcat iam getting error 404 Login.html not found....
    so plz kindly help me this my first servlet .....

    There seems not to be any '.html' in your url-pattern
    <url-pattern>Login</url-pattern>- so i presume you should use
    http://yourhost/Logininstead.

  • 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

Maybe you are looking for

  • Report Painter Report - Leading White Spaces in Cost Element

    When calling up a report painter report, e.g. S_ALR_87013613, with cost element characteristic in Office integration/Microsoft Excel as output parameters, the cost element (row item) is indented with white spaces.  The number of white spaces seems to

  • Network adapter could not resolve the connection in sql developer

    hi, i had installed oracle 11g , and then i try to connect the sys/system user using sql developer and sqlplus , but i got following error are display , plz give some idea regards venki

  • How do you create a wsdl file from a FM?

    Hello friends, Could some one please let me know how to create a wsdl file from a function module? I have gone up to the stage of creating webservice  and also released it for SOAP runtime using tranasaction code wsconfig. But I don't know how to pro

  • Suddenly quits applications

    So my iPad is suddenly quitting its applications constantly. Applications it quits out of most are Safari, Mail, and iBooks. Mail started being sluggish to respond about a week ago but it seemed to be an irregular problem. Now all of those Apps are q

  • Java user locking

    Hi gurus, Our SLD user is constantly being locked out. We have checked SLD config on all SLD clients and they are all testing successfully yet our slddsuser still gets locked every few minutes. The security log on the SLD server shows that our user i