tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Micael Padraig Og mac Grene" <caraun...@harbornet.com>
Subject Re: TC 4.0 newbie - servlet app won't run
Date Thu, 22 Nov 2001 06:21:36 GMT
Mark,

Scott is right, of course, but there is no reason to use a url when in fact
you are just using a tag or a name.  It is misleading, in my opinion.  In
Scott's code, substituting <form action="pudding" method="post"> for <form
action="/servlet/servlet" method="post"> works just as well as long as you
use <url-servlet>pudding</url-servlet> instead of
<url-pattern>/servlet/servlet</url-pattern>.  This is not an incidental
matter.  The latter for gives the mistaken impression that the semantics of
url-pattern has something to do with urls, classpath, etc, which it does
not.  Once you free yourself of the meaningless references to urls in
<url-pattern> you can begin to use it for passing code, keys for the
controller servlet, etc.  As long as you stick with url-look-alikes, you
have misleading code.  Typically, a Tomcat Model 2 Architecture uses this
possible way of employing and passing free semantics to the controller.  The
issue, in my opinion, is not a trivial matter in Model 2 design patterns.




-----Original Message-----
From: Scott Ahten <pixel@pixelfreak.net>
To: Tomcat Users List <tomcat-user@jakarta.apache.org>
Date: Wednesday, November 21, 2001 9:20 PM
Subject: Re: TC 4.0 newbie - servlet app won't runThi


>Mark,
>
>The servlet tag is used to assign a name to a particular servlet class
>file.
>
> <servlet>
>           <servlet-name>myservlet</servlet-name>
>           <servlet-class>myservlet</servlet-class>
>       </servlet>
>
>This would attempt to assign the name 'myservlet' to the class
>'myservlet.class.'
>
>The servlet-mapping tag defines the pattern or 'location' of a named
>servlet from the root of your context. This means that ....
>
><servlet-mapping>
>           <servlet-name>myservlet</servlet-name>
>           <url-pattern>/classes</url-pattern>
>       </servlet-mapping>
>
>if this were the ROOT context, this would map your servlet at /classes
>and your form action would need to be defined as
>
><FORM ACTION="/classes" method="POST">
>
>A more common mapping for servlets is
>
><servlet-mapping>
>           <servlet-name>myservlet</servlet-name>
>           <url-pattern>/servlet/myservlet</url-pattern>
>       </servlet-mapping>
>
>which would have a coresponding form tag of
>
><FORM ACTION="/servlet/myservlet" method="POST">
>
>
>~Scott
>
>Mark wrote:
>
>>I installed Tomcat 4.0.1 under Win 2k using JDK 1.3 and able to run the
>>example servlets, but not my own.  My html displays and I can execute my
>>JSPs, but a POST to a servlet does not work (this app has run under Forte
>>and VA Java in the past).   I get a 404 error with "the requested resource
>>(/myservlet) is not available". Since the examples work, I have to assume
>>it's something in my configuration. Any help figuring out why the servlet
>>won't run would be *greatly* appreciated.  I suspect it's something
>>simple/braindead on my part.
>>
>>
>>o  My directory structure for the app:
>>   TomcatHome
>>        |
>>        +--webapps
>>              |
>>              +--myapp\.jsp, .html .gif
>>                 |
>>                 +--WEB-INF\web.xml
>>                       |
>>                       +--classes\.class files
>>
>>
>>o  My html POST stmt. I've tried various path prefixes to myservlet, eg
>>   "classes/myservlet".  As with the Tomcat examples, this servlet has no
>>   package:
>>
>>    <FORM ACTION="/myservlet" method="POST">
>>
>>
>>o  My web.xml - I know Tomcat's seeing/parsing this because if I
deliberately
>>   make a typo I get an error upon startup:
>>
>>     <?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>
>>       <!-- Define servlets that are included in the application -->
>>       <servlet>
>>           <servlet-name>myservlet</servlet-name>
>>           <servlet-class>myservlet</servlet-class>
>>       </servlet>
>>       <servlet-mapping>
>>           <servlet-name>myservlet</servlet-name>
>>           <url-pattern>/classes</url-pattern>
>>       </servlet-mapping>
>>    </web-app>
>>
>>
>>o  Update to server.xml
>>
>>   <Context path="/myapp" docBase="myapp" debug="0">
>>       <Logger className="org.apache.catalina.logger.FileLogger"
>>               prefix="myapp_log." suffix=".txt"
>>               timestamp="true"/>
>>   </Context>
>>
>>
>>
>>
>>
>>
>>
>>
>>--
>>To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>>For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
>>Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
>>
>>
>>
>>
>
>
>
>
>
>--
>To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
>Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
>
>


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message