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.

Similar Messages

  • Need help compiling an EJB with Apache Tomcat 5.5

    Hi everyone, I need some help. I�m writing an EJB that has to run on Apache Tomcat 5.5.
    I�m importing the javax.ejb.* library, but Eclipse can�t find the JAR it needs. Where can I find this JAR? Do I have to download or what?
    Thanks a lot.

    Thanks, I�ve already downloaded the javaee.jar from the Sun webpage. As you can see I�m quite new to EJB developing. I want to create an EJB that will get some information from a database and send it back to a servlet, and then a web page. I've been browsing the JBoss page, and I see there are LOTS of versions. Any suggestion, regarding which version I shoud use for this? Thanks a lot again.

  • BO XI3.1 servicepack 6 with Apache Tomcat 6/7

    We are planning to upgrade BO XI 3.1 sp5 to servicepack 6.
    SAP recommends to upgrade Apache Tomcat 5.5 too (to version 6 or 7)
    Our IT-department wants to know if, when you install SP6, Apache Tomcat 6/7 is also automatically installed (Does AT 6/7 come with SP6) , or is it two separate installations?
    I think it is the last option, am I right?
    Thanks in advance!

    Hi,
    you have to possibilities here:
    1. Install it manual as in SAP Note - 1880756
    2. Install it with the SP06 Update. Here it is only available when using the CLI variant, not the GUI Variant. See SAP Note - 1844998
    If i where you, i would choose the second option.
    Regards
    -Seb.

  • Print Server with Apache Tomcat 6.0 and Cocoon 2 Problem...

    Hi,
    My company have 2 server, (9i - APEX_3.1.2.00.02) and (10g - APEX_3.1.0.00.32), both in Http server running in OEL 4.0.
    I tried the following cocoon installation in other window server,
    http://carlback.blogspot.com/2007/03/apex-cocoon-pdf-and-more.html
    and I set both APEX Instants Setting, the report printing setting according to the installation above.
    The 10g apex run perfectly, however the 9i apex cannot print pdf report. the following is the error message show when i click on the export pdf button.
    The webpage at http://server9i:7777/pls/apex_camnet/f?p=105:1:3689040380318743457:PDF: might be temporarily down or it may have moved permanently to a new web address. Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error.
    Before i add the print server to (9i), the pdf can be export, however no content inside the pdf, some corrupted detected, but when I added the report printing setting, the message above shown.
    Is this because of the version of database? or the version or APEX? or other matter i did not aware?
    Pls Help.
    ~ vincent
    Edited by: kiddoo_81 on Dec 23, 2010 2:08 PM

    Hi,
    Anybody? any suggestion?
    Thank you.
    ~vincent

  • Multiple Realms in Apache Tomcat

    Sorry, if this is the wrong forum, but its the closest match i could find.
    I am trying to run 2 servlets that use apache tomcat's j_security with a FORM login to authenticate clients. I would like these 2 servlets to be authenticated by having j_security look in two different tables in a MS SQL 2000 Server database.
    I have read up a lot on apache tomcat's site, and the sense that i've made of it is that i need to have multiple realms, and in order to do that i need multiple contexts. I've tried wrapping my realm tag in a context tag but it doesn't work. What am i missing?
    thanks.
    <Context path="/servlet/" docBase="ROOT/WEB-INF/classes" reloadable="true" />
              <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
         driverName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
         connectionName="sa" connectionPassword="******"
         connectionURL="jdbc:microsoft:sqlserver://localhost:1433;databaseName=ConcernCheck;selectMethod=cursor;"
    userTable="Operator" userNameCol="Username" userCredCol="Password"
         userRoleTable="Operator" roleNameCol="Role" />
    </Context>
    Thanks

    Hi!
    I have the same problem! did you solve this problem? can you give me a hint?
    Tnx,
    Stanislav

  • How to integrate Apache Web Server and Apache Tomcat 4.0 ?

    <pre>
    Hi All,
    Can anyone give me a detailed description(or url that tells so) of how to install the Apache Web Server, Apache Tomcat Server4.0 and Integrate both of them.
    Still now I am using Apache Tomcat 4.0 as a standalone application and now I want to learn how to install,use Apache Web Server and integrate this with Apache Tomcat.
    Please point me to exact location,url to download the recent Apache Web Server and,
    Can I use my existing Standalone Apache Tomcat 4.0 to integrate this with Apache Web Server that I am going to download.
    A detailed explanation of how to integrate both is very helpful.
    Thanks in advance.
    <pre>

    The way to integrate Apache Web Server & Apache is very easy. The first step is download the library to connect both servers. This library can be download from http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0/bin/webapp-module-1.0-tc40-windows.zip.
    Copy the files to APACHE_HOME\modules and open httpd.conf to change any lines:
    You find the section "LoadModule" and you add the next lines:
    LoadModule webapp_module modules/mod_webapp.so
    AddModule mod_webapp.c
    And the end of the file you must add these lines:
    WebAppConnection conexion warp localhost:8008
    WebAppDeploy examples conexion /examples
    The first parameter -2nd line- (examples) is the URL name application, the second is the connection's name and the last parameter is the application's name. This name is the same which in servlet.xml.
    At last you can add one more lines to check the module's configuration:
    WebAppInfo /webapp-info
    If you visit http://<yoor_host>/webapp-info you can see the configuration.

  • How to run different versions of Apache Tomcat on one machine?

    Hi, I am developing a web application. My application runs on Apache Tomcat 5.5.12 and i am using jdk 1.5_03. My application detects files that are automatically scanned to a specific directory and queues them for capture in a database.
    The scanner software (HP Toolbox) is also a web application (Unfortunately), it installs itself with Apache Tomcat 4.03. It is "wired" in a specialised way (not the way you would usually deploy web apps). So the Web server is customised by HP (Hewlett-Packard).
    The scanner needs this software running inorder to automatically scan to a specified folder. You can only specify local directories to scan to from the Toolbox application
    There seems to be some resource conflict when I run my version of Tomcat when the Toolbox application is running (I get an exception
    ..IllegalMonitorState...current thread not owner). Visa vera is alos true..if i start my application first the Toolbox application won't run.
    I tried to install the Toolbox app on another machine and monitor a directory remotely...this doesn't work because you can't read or write to remote files from a servlet or JSP.
    I tried loading my application in the web apps directory of Apache 4.03 but it did not detect my application. I don't know how to configure the Tomcat customised by HP.
    How can i go about this problem? Is there a way of running two versions of Apache Tomcat on one machine?
    Thanks
    Parthiv

    This is the exception i get when i try to run my version of Apache Tomcat when the Toolbox is running: My application is set to port 80.
    Exception in thread "http-80-1" java.lang.IllegalMonitorStateException: current thread not owner
         at java.lang.Object.notifyAll(Native Method)
         at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1216)
         at java.lang.Thread.run(Unknown Source)

  • Securite apache/tomcat

    Hi!
    I have a application written in jsp/servlets. I has some static resourses that tomcat protects when running it as standalone. But when I deploy this web-app on a server with apache/tomcat apache serves those static files that I would like to be protected.
    How can I tell apache to use tomcats security constraints and knowing when a user has logged in and not?
    Thanks in advance
    Roland Carlsson

    I just read an article about securing tomcat that is riding behind apache. Free chapter from oreilly at:
    http://www.oreilly.com/catalog/tomcat/chapter/ch06.pdf
    the pdf does a decent job of showing how to REALLY secure tomcat. the above post also shows how to do it... apache doesn't know anything about tomcat's security, nor does it know about resources that the webapp spec say are protected by the container. SO, you have to explicitly tell apache not to serve from those directories. alternatively, not having apache have access to the tomcat install location is not a bad idea either, and you then ONLY hand *.jsp requests to tomcat through the connector. then, as long as your jsps aren't in WEB-INF (which is actually used as a security protection if you set things up right for heavy included systems), apache can't get to WEB-INF.
    dukes?

  • Root certificate issue with keytool (Tomcat)

    I have:
    - Created a certificate request
    - Sent the request to a CA (Verisign affiliate)
    - Received the certificate
    - Installed the certificate
    When I surf to the page that utilizes the certificate, I receive an error message:
    "This CA Root certificate is not trusted. To enable trust, install this certificate in the Trusted Root Certification Authoritues store"
    I use the certificate with Apache Tomcat. The root certificate is imported into the cacerts file. I use the following commands to prepare and install the certificate:
    keytool -genkey -dname "cn=somesite.com, ou=IT, o=SomeCompany, l=Stockholm, s=Sweden, c=SE" -keyalg "rsa" -alias SomeAlias -keystore D:\ssl\SomeFolder\keystore.jks -storepass SomePassword -validity 360
    keytool -certreq -alias SomeAlias -file D:\ssl\SomeFolder\MyCSR.csr -keystore D:\ssl\SomeFolder\keystore.jks -storepass SomePassword
    keytool -import -trustcacerts -alias SomeAlias -file D:\ssl\SomeFolder\MyCert.cer
    I don't see why I am having this problem. Please help me. I've spend several hours with different problems regaring the keytool utility, and the current certificate is valid for only three more days.
    Thanks in advance!
    Best regards,
    Bj�rn

    I am guessing that your ks file is not visible by the default config for Tomcat
    Check in your tomcat/conf/server.xml
    the config for the SSL Coyote Connector config block... you must specify the keystoreFile, maybe keystorePass... see http://jakarta.apache.org/tomcat/tomcat-5.0-doc/ssl-howto.html under Edit the Tomcat Configuration File
    -Jay

  • GPL Licence, Apache Tomcat and J2EE5

    Hello !
    I'd like to know if it is possible for a company to sell a server with apache tomcat and J2EE 5 ?
    Does this company have to pay fees to Sun ?

    Hi,
    I have same problem with B1 9.1, Version for Hana, but I cannot apply the workaround of San Xu on linux server.
    I try a clean installation of 9.1 servertools on linux server, but on windows server, when I run the Upgrade.exe for the databases, the error appears: "Could not connect to licence server; enter valid password".
    I've the italian localization.
    Can someone help me?
    Thanks & Regards
    Valerio

  • Apache Tomcat 4 error - cant fine a servlet

    Hi,
    I have a web.xml file that defines classes and url patterns fine. For some reason though, which I cant work out, even when I add the following to web.xml, Tomcat says it cant find the requested resourse.
    http://localhost:8080/servlet/SimpleShoppingBasket
    <servlet>
    <servlet-name>SimpleShoppingBasket</servlet-name>
    <servlet-class>SimpleShoppingBasket</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>SimpleShoppingBasket</servlet-name>
    <url-pattern>/servlet/SimpleShoppingBasket</url-pattern>
    </servlet-mapping>
    The error displayed is:
    HTTP Status 404 - /servlet/SimpleShoppingBasket
    type Status report
    message /servlet/SimpleShoppingBasket
    description The requested resource (/servlet/SimpleShoppingBasket) is not available.
    Apache Tomcat/5.5.17
    Every other servlet I have runs fine except this one. I have checked the spelling of the class and it is correct. I am nearing my wits end!
    Please help! What could be wrong? Is there a cache that I can delete somewhere maybe?

    Try putting the servlet class into a package. There could be access problems with it being in the "unnamed" package
    Check the tomcat logs for any errors that servlet may be creating ([TOMCAT]/logs directory)
    Also is your web app installed in the ROOT directory or in its own context?
    If in its own context then the url would be http://localhost:8080/mycontext/servlet/SimpleShoppingBasket
    What do the other (working) servlet definitions look like?
    How are they different from this one?

  • Servlet 3.0 with annotations & tomcat 7

    Hey Folks,
    I am at my wits end here trying to deploy a servlet with annotations.
    I have managed to successfully deploy it without annotations i.e via the web.xml & everything is fine but I get a status 404 when trying to deploy with annotations.
    I am running tomcat :
    Server version: Apache Tomcat/7.0.12
    Server built: Apr 1 2011 06:13:02
    Server number: 7.0.12.0
    OS Name: Linux
    OS Version: 2.6.35-28-generic
    Architecture: i386
    JVM Version: 1.6.0_20-b02
    JVM Vendor: Sun Microsystems Inc.
    I followed the spec so I am sure I am doing everything right from a coding point of view, there is no mention of this servlet what so ever in the apps web.xml
    WebServlet(urlPatterns={"/HelloServlet3"})
    +public class HelloServlet3 extends HttpServlet {+
    +@Override+
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    +...+
    +}+
    The compiled class file (wihin package moreservlets) is located in the following directory
    *~/tomcat/apache-tomcat-7.0.12/webapps/onjava/WEB-INF/classes/moreservlets*
    The application onjava is mapped in the server.xml
    view plaincopy to clipboardprint?
    +<Context path="/onjava" docBase="/home/rob/tomcat/apache-tomcat-7.0.12/webapps/onjava" debug="0" reloadable="true" />+
    This application has both annotated servlets which don't work & regular servlets with web.xml which do work, can I mix both for onjava above?
    Any help greatly appreciated
    Thanks
    Rob

    Apologies for that, but I sent that thread a few days ago on javaranch but got no reply so I thought I would try this site, I intend to post the solution to both forums.
    Yes that was the issue I changed to the 3.0 version as specified below & all worked well
    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">
    & it worked, thanks for your help!
    Regards
    /Rob

  • JSP mapping with Tomcat 5.0.27

    With Jakarta-Tomcat 5.0.27 is it possible to put a JSP file in a sub-directory of a web application and be able to "servlet-mapping" it to only create one object? If so how do you write the web.xml entry? I only want to create one InitTest object, not two of them!
    If I place InitTest.jsp in the following directory structure:
    C:\tomcat\webapps\web-app\subDirectory\InitTest.jsp
    This web.xml entry does not work:
         <servlet>
              <servlet-name>InitTest</servlet-name>
              <jsp-file>/subDir/InitTest.jsp</jsp-file>
         </servlet>
         <servlet-mapping>
              <servlet-name>InitTest</servlet-name>
              <url-pattern>/InitTest.jsp</url-pattern>
         </servlet-mapping>When I use this link:
    http://localhost:8080/web-app/subDir/InitTest.jsp
    I get "jsp" as the servlet name
    and
    When I use this link:
    http://localhost:8080/web-app/servlet/InitTest
    I get "InitTest" as the servlet name
    How do I map InitTest.jsp correctly when it's placed in a sub-directory of the web application's directory?

    dear friend...y do you want to map your jsp page?? you can directly access your jsp from your location. You dont needd to map in the web.xml. You need to map only servlets not jsps
    regards
    shanu

  • Using tomcat 5 along with apache 2.2

    hi
    i am facing a strange problem
    i am trying to build a web application using servlets with tomcat 5 and apache 2.2 and i am using oracle 10g as the data base
    now when try to access the database from my pc it works fine but when i try to access it from other pc through lan its showing an exception
    i am using mod_jk connector to forward the servlets requests to tomcat.
    log file looks like this
    2009-02-01 00:04:07 StandardContext[manager]HTMLManager: init: Associated with Deployer 'localhost'
    2009-02-01 00:04:07 StandardContext[manager]HTMLManager: init: Global resources are available
    2009-02-01 00:04:07 StandardContext[manager]HTMLManager: list: Listing contexts for virtual host 'localhost'
    2009-02-01 00:04:23 StandardWrapperValve[home]: Servlet.service() for servlet home threw exception
    java.lang.NullPointerException
    at Home.doGet(Home.java:26)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Unknown Source)
    please help me its my semister project
    thanking you

    ronit wrote:
    java.lang.NullPointerException
    at Home.doGet(Home.java:26)Some object reference at the mentioned line inside the mentioned method of the mentioned class is null while the code is trying to access/invoke it.
    The solution should be obvious: make sure that it is not null, or only access/invoke it when it is not null.
    That said, and apart from this specific problem, you should always be placing classes in packages. Not doing so is a bad practice and also asking for trouble.

  • Integrate Tomcat with apache

    I need a procedure to check my installation of Tomcat 4.0.3 and it¹s
              integration with apache. I was told I need mod_jk, but I can¹t find it even
              in the source files of tomcat. Any word on where I can find it?
              Any procedures and insights would be greatly appreciated, thank you!
              Tim Best
              [att1.html]
              

    I am ttrying integrate tomcat/aoache on my local machine.But i can able to run html files only.No jsp,servlets.can you tell me how did u configure that.

Maybe you are looking for

  • Is iPad Mini with Retina display screen a gorilla glass?

    Is iPad Mini with Retina display screen a gorilla glass?

  • Front row video doesnt work any more....

    After around two months of complete operation front row now doesnt play videos, when selected i get the following message: 'YOu dont have any movie files in the movies folder in your home folder' In the finder window, the little blue movie icon isnt

  • greater than symbol inserted at bottom of php pages in all pages

    I've coded for years and never seen this.  At the bottom of all of my pages, no matter what I do, the following gets added in "<html>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"  obviously these symbols show up and make all my webpages look awful.  I de

  • Set attribute to a Jfield to return type number from Lov

    in my lov , i need to return type number and put it in the Jfield . after doin some search , i found the method to set the attribute on that field. PLease and need to send me any URL of doing that method if there is one. (returning type number from L

  • Cursor going haywire!

    My keyboard is POSSESSED! Problem started this a.m. that I'll be typing and suddenly realize that my insertion point has jumped around. Happens at random in all software (mail, address book safari). Software up to date. Re-booted, no help.