Sorry, here's some more information then...
I have read the servlet spec (2.2 and 2.3), and have looked at web.dtd as
well. Normally, as you say, each web application should have a copy of
"web.xml" in its "web-inf" folder. Tomcat additionally allows one "super
web.xml" in Tomcat's "conf" folder, to specify default values. As I deploy
onto a variety of servlet containers, I try to use a clean, non-server
specific, approach to designing and implementing applications. So I don't
want to rely on Tomcat's "web.xml" file (which is unlikely to exist, at
least in the same form, with other servlet containers).
Web.xml is supposed to define *all* servlets. As JSP processing is itself
handled by a servlet, this too must be defined in web.xml (as is the case
with the default under Tomcat). Furthermore, Tomcat's User Guide states
that there should be no problem overriding settings from the default web.xml
within a webapp's web.xml. This is where I'm having the problem, as instead
of overriding properties, it's cancelling them out.
At this stage, it's mainly hypothetical testing that I'm doing. I would
like to understand more the mechanism used by Tomcat however. This is
practical when it comes to deploying on another servlet engine (whether it's
Weblogic, or another Tomcat with a different "default" web.xml, or
whatever), as I'd like to be able to create the "mywebapp.war" file without
having to merge the default web.xml with the individual webapp's web.xml.
The need for merging is to allow a complete and clean deployment descriptor.
Note that I'm not referring to the "example" webapp supplied with Tomcat,
I'm referring instead to the "default" web.xml as found in Tomcat's "conf"
folder.
I don't have any application-specific deployment information as yet, I'm
just trying to become familiar with the basics to avoid getting lost later
on. The application contains one JSP, and one "hello world" HTML page. The
JSP code is as follows:
<%@ page language="java" %>
<%! static int hits = 0; %>
<html>
<head><title>JSP Example</title></head>
<body>
<h1>JSP Example</h1>
<p>Hit count: <%= ++hits %></p>
</body>
</html>
Really simple. With no web.xml in the context, it displays fine. However,
with a copy of the default web.xml (and its definition of the "jsp" and
"invoker" servlets), trying to access the JSP page results in a "HTTP 404
Not Found" message, created by Tomcat. At startup, there are also the log
messages on stdout and stderr that I included in an earlier posting (see
below as well, in my original message).
I don't see why I can't have a web.xml file based on the default if Tomcat's
User Guide states that this allows harmless overriding of existing settings.
Even if I only add a few servlets and decide to use Jikes instead of Javac
for the JSP-compiling servlet for example, I'd still like to know if I can
work this way.
Thanks in advance to those who can reply!
-Chris
----- Original Message -----
From: "Michael Sweeney" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 24, 2001 5:01 PM
Subject: Re: What's going on with web.xml ?!
> Chris,
> I'm not sure I understand what you are doing exactly. You've mentioned
that
> you put a copy of the default web.xml file in your application directory,
> but you have mentioned that you edited the file to reflect your
> application, so I'm beginning to guess that you haven't done that. If you
> haven't already done this, read Chapter 13 of the Servlet specification
> (http://java.sun.com/products/servlet ) to get an idea of what the
> different elements are used for. I'm by no means an expert on this, but
the
> web.xml file is the "deployment descriptor" of a web application - if you
> put one in your application's directory structure, you need to edit it to
> provide the information that's specific to your application. The default
> web.xml file isn't going to help you in your application deployment
because
> it has information specific to the servlet container itself. You might
take
> something like the web.xml file from the examples directory and edit it to
> represent your specific web app. If the web.xml file doesn't describe the
> specific application, it doesn't really have any point to being there.
Hope
> this helps.
>
> Michael
>
>
> At 11:02 AM 4/24/01 +0200, you wrote:
> >This follows on from my questions from yesterday... still not solved...
:-(
> >
> > >From a fresh Tomcat install -- which worked, including the addition of
a
> >simple "hello world" type context of my own -- I then tried to add my own
> >custom "web.xml" file. As soon as I put this into my context's WEB-INF
> >folder, with no changes to the "default" version of "web.xml", I got the
> >following messages in the logs :
> >
> >[stdout]:
> >Starting tomcat. Check logs/tomcat.log for error messages
> >cannot load servlet name: jsp
> >cannot load servlet name: default
> >
> >[stderr]:
> >2001-04-23 03:20:05 - ContextManager: Adding context Ctx( )
> >2001-04-23 03:20:05 - Ctx( ): Removing duplicate servlet jsp
> >jsp(org.apache.jasper.runtime.JspServlet/null)
> >2001-04-23 03:20:05 - Ctx( ): Removing duplicate *.jsp ->
> >jsp(org.apache.jasper.servlet.JspServlet/null)
> >2001-04-23 03:20:05 - PoolTcpConnector: Starting Ajp12ConnectionHandler
on
> >8007
> >2001-04-23 03:20:05 - PoolTcpConnector: Starting Ajp13ConnectionHandler
on
> >8009
> >
> >I assumed that placing "web.xml" in a WEB-INF folder with Tomcat allowed
the
> >developer to override default settings. However, it seems that instead
of
> >overriding settings, this cancels them out!!! So, I tried removing the
> >default webapps in the "webapps" folder (admin, test, root, example), and
> >removed tomcat/conf/web.xml (the default), as well as my own one.
> >
> >To my surprise, this actually still compiled my JSP pages! Despite there
> >being no definition anywhere of a servlet to handle JSP requests! (It's
> >worth noting here that I'm accessing Tomcat via its built-in HTTP
connector,
> >not Apache or whatever).
> >
> >So I decided then to put a copy of the default web.xml file within the
> >WEB-INF folder of my context (without restoring the default in
tomcat/conf).
> >And another surprise: compilation failed with the exact same messages as
> >above in STDOUT and STDERR, complaining that these servlets were already
> >defined and would therefore now be removed as they were supposedly
declared
> >twice...
> >
> >Help! How does this work? What am I missing? How can I define a full
> >"web.xml" file for my context without these problems? I may for example
> >wish in some contexts to use the Jikes compiler instead of Javac, which
> >requires overriding the "jsp" servlet (and this is what I'm stuck on).
> >
> >Many thanks for help,
> >Chris Brown
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets