Women in Technology

Hear us Roar



Article:
  Deploying Web Applications to Tomcat
Subject:   make it work with version 4.18 and above
Date:   2003-05-14 08:20:02
From:   hkubba
An important addition is to be added here: in the web.xml we must have 2 tags inside the < web-app> tag, those are <servlet> and <servlet-mapping> so when the article says :


<servlet>
<servlet-name>login</servlet-name>
<servlet-class>com.onjava.login</servlet-class>
</servlet>


another block should be added:


<servlet-mapping>
<servlet-name>login</servlet-name>
<url-pattern>/login</url-pattern> < !-- note it is /login not login -->
</servlet-mapping>


this will make it work

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • make it work with version 4.18 and above
    2003-05-25 09:10:52  anonymous2 [View]

    I have tried this suggestion and I still could not get it to work. I am running Tomcat 4.1.24 under Windows 2000 (Professional).

    My web.xml file looks as follows:

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

    <servlet>
    <servlet-name>login</servlet-name>
    <servlet-class>com.onjava.login</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>login</servlet-name>
    <url-pattern>/login</url-pattern>
    </servlet-mapping>

    </web-app>

    My directory structure looks as follows:
    <TOMCAT_HOME>\webapps\onjava
    =====> images (directory)
    =====> login.jsp
    =====> welcome.jsp
    =====> WEB-INF
    ==========> web.xml
    ==========> classes
    ===============> com
    ====================> onjava
    ==========================> login.class
    ==========================> login.java

    I have set the ServletContext in Tomcat's server.xml. My XML statement looks as follows:
    <Context path="/onjava" docBase="onjava"
    debug="1" reloadable="true"/>

    I was successfull in deploying an HTML and JSP application using Tomcat's administration tool and ant. I am always getting the HTTP 404 error when I am deploying servlets.

    Any help is highly appreciated.

    Thank you.
    • make it work with version 4.18 and above
      2003-06-19 02:58:58  anonymous2 [View]

      With Tomcat 4.1.24 (4.1.18 and above?)
      if you want to use /servlet/* path,
      you need to uncomment the invoker mapping
      in <TOMCAT_HOME>\conf\web.xml
      or include the invoker mapping:

      <servlet-mapping>
      <servlet-name>invoker</servlet-name>
      <url-pattern>/servlet/*</url-pattern>
      </servlet-mapping>

      in your application's own web.xml.