#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    STL
    Posts
    13
    Rep Power
    0

    Unhappy Servlet activation in sum one app server


    I deployed my web app using sun one app server.

    I can access my app at :
    http://localhost/webapps-xmltreeview/main.html

    The main.html has 3 frames, in which in the top frame (top.html) I'm calling my only servlet (getxml):

    <html>
    <head>
    <title>xmltreeview</title>
    <base target="contents">
    </head>
    <body>
    <form METHOD="get" ACTION="/servlet/getxml">
    <INPUT TYPE=submit name=submit Value="call getxml servlet">
    </form>
    </body>
    </html>

    But it does not work (sometimes I get 404 error and sometimes it just hangs for a long time...)
    The same happens when I call the servlet directly (http://localhost/webapps-xmltreeview/servlet/getxml).

    My web.xml is:
    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/j2ee/dtds/web-app_2_2.dtd'>

    <web-app>
    <display-name>webapps-xmltreeview</display-name>

    <description>
    The jakarta-tomcat-4.0.3 sample XMT treeview app.
    </description>

    <distributable></distributable>

    <servlet>
    <servlet-name>getxml</servlet-name>
    <servlet-class>samples.webapps.xmltreeview.servlet.getxml</servlet-class>
    </servlet>

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

    <welcome-file-list>
    <welcome-file>main.html</welcome-file>
    </welcome-file-list>

    </web-app>

    The servlet class exist in:
    Directory of C:\Sun\AppServer7\domains\domain1\server1\applications\j2ee-modules\webapps-xmltreeview_1\WEB-INF\classes\samples\webapps\xmltreeview\servlet

    05-08-03 08:52a <DIR> .
    05-08-03 08:52a <DIR> ..
    05-08-03 08:52a 1,072 getxml.class
    (See attched image)
    and was packaged as:
    package samples.webapps.xmltreeview.servlet;

    What am i doing worng
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    You have a couple of things going on. First of all, there are two ways to call a servlet from tomcat:
    [list=1][*]use the host/webapp/servlet/package.servletclassname convention[*]or map the servlet and call it using host/webapp/servletName[/list=1]

    So, using the first method your link would look like this (Note: I put spaces after the http so the message board would not try to make a link out of it):
    http: //localhost/webapps-xmltreeview/servlet/samples.webapps.xmltreeview.servlet.getxml

    And since you have a servlet mapping in your web.xml, you could call it like this
    http: //localhost/webapps-xmltreeview/getxml



    Now secondly, lets examine your forms action. You ahve
    Code:
    <form METHOD="get" ACTION="/servlet/getxml">
    This makes the browser create a link like this
    http: //localhost/servlet/getxml

    This is clearly not what you want. Given the first point I made, you have two choices for correcting this:
    Code:
    <form METHOD="get" ACTION="/webapps-xmltreeview/getxml">
    
    OR
    
    <form METHOD="get" ACTION="/webapps-xmltreeview/servlet/samples.webapps.xmltreeview.servlet.getxml">
    Hope that made sense.
    Last edited by Nemi; May 9th, 2003 at 11:51 AM.

IMN logo majestic logo threadwatch logo seochat tools logo