tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Malladi, Sasikanth " <sasikanth.mall...@citi.com>
Subject RE: Newbie question
Date Mon, 24 Aug 2009 19:15:29 GMT

Malladi,

On 8/24/2009 10:36 AM, Malladi, Sasikanth wrote:
> I'm using "Core Servlets" by Marty Hall as a guide.

Which edition? It may be out of date.

> I've created a servlet, HelloServlet. Well, it just says "hello".

Can you post the code?

> I've compiled it and put the class file into .../install_dir/webapps/ROOT/WEB-INF/classes/.
> I've enabled the invoker servlet by uncommenting it in .../install_dir/conf/web.xml.

This is fine for testing purposes, but you really should not use the
invoker servlet. Instead, it's easy to enable your servlet in your own
webapp's web.xml:

<servlet>
  <servlet-name>Hello</servlet-name>
  <servlet-class>HelloServlet</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>Hello</servlet-name>
  <url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>

> I've enabled the servlet reloading in .../install_dir/conf/context.xml.

You should probably not be modifying CATALINA_HOME/conf/context.xml.
Instead, create a file in webapps/ROOT/META-INF/context.xml and put your
configuration there. Remember not to set the "docBase" or "path"
attributes in your <Context> element.

> However, I can't see the servlet in http://myhost:8008/servlet/HelloServlet.
>
> What am I missing?

I suspect you have a package/class name mismatch with your .class file
and the URL you're using to access the servlet. Disable the invoker
servlet, write a proper web.xml file, and post your code. That will help
a lot.

- -chris


Chris, I'm using an earlier version, but I'm also following www.coreservlets.com to make note
of updates.

However, I've updated the web.xml per your suggestion and it worked like a charm.

Thanks for your help,
Sashi

Mime
View raw message