Ahh... tomcat/servlet spec 101 questions.

Here's the scoop:

1. Don't enable the invoker servlet unless you have an unbelievably excellent reason for it. If you are just starting to learn servlet technology, you are better off learning best practices up front. Mess with the invoker after you have a firm grounding in the technology and understand the ramifications of using it. To my knowledge, only the really old books and articles ever even mention the invoker servlet much less advocate enabling it. That may be your clue to stop reading it and get something newer.

2. Your servlet class needs to be in a package. That means you have 'package com.mycomany.myproject ;' at the top of your java source code and you place the class itself in WEB-INF/classes/com/mycompany/myproject of your webapp. It can also be jarred and the .jar file placed in WEB-INF/lib but since you are learning, this isn't necessary.

3. Write a web.xml file with a proper servlet mapping in it. There are a lot of resources out on the web describing this including the most excellent servlet specification which should become your best buddy. I believe David Brown posted a link to it. If you are relying on a book, make sure it covers at minimum servlet spec 2.4, preferably servlet spec 2.5 and tomcat 6 since that's what you are working with. 4. The second two places you put the context fragment work -- just use only one or the other to avoid confusion. Also given where you are storing your webapp, the docbase and path attributes are really not necessary. The docBase will be picked up automagically and the path will be named after the context fragment file in conf/Catalina/localhost or your webapp's docBase.

5. If you are still having trouble, the relevant parts of your setup will go miles towards helping solve your problems. In most cases, that amounts to your context xml fragment, web.xml file and folder layout of your webapp.

--David

ilene m wrote:
--- ilene m <[EMAIL PROTECTED]> wrote:

Date: Thu, 7 Feb 2008 19:50:18 -0800 (PST)
From: ilene m <[EMAIL PROTECTED]>
Subject: can't get servlets to run
To: users@tomcat.apache.org

Hi,

I cannot get servlets to run outside of the servlet
examples link off of the main page.
I'm getting the ole 404 The requested resource -
servlet - is not available.

I have tried the 6.0.14 zip file and a
"preconfigured
6.0.10 version of of the coreservlets.com site.

i've tried loading 6.0.14 twice.  Everything else
runs
but the servlets.  In the first iteration of 6.0.14
i
had html, jsp, php, php accessing mysql running
happily.  Thought it might have been something i did
to make php happy so i took a clean version but it
didn't help.

When i loaded 6.0.14 i tried to run servlets by
using
the invoker servlet.  Uncommented the invoker
servlet
and it's mapping in web.xml and added
privileged="true" to context.xml and threw a
HelloWorld.class file into
webapps\Root\WEB-INF\classes dir accessing via
http:\\localhost:8080\servlet\HelloWorld.

I also tried my own app dir and a context fragment
file. Tried putting the context fragment file in tomcat\conf\Catalina\localhost\myApp.xml, tomcat\conf\Catalina\localhost\myApp\myApp.xml and tomcat\webapps\myApp\META-INF\context.xml.
Tried changing up the docbase.

Tried raising the logging level to see if anything
useful would pop out.  NADA

Wondering if I'm missing an environment var.

Any help would be GREATLY appreciated.

Thanks for your time.





____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs




      
____________________________________________________________________________________
Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to