Tomcat Servlet not being recognized or something...

6

6e

Hi, thanks for reading.

I have created a simple servlet (that compiles properly) and compiled
it into a war file. I deployed the war file in the webapps directory,
and it is extracted appropriatly into a directory listed as

webapps/myapp/myapp.class

however when I browse to "host:8080/myapp/" all I get is a directory
listing. I tried to add a web.xml file, however it does not show up in
the listing, even after stopping and starting the service.

I also tried putting it into a structure (found in tutorials)
..../Web-INF/classes/com/mycompany/myapp, but this did not make it run
either...

is there something that Im missing? any ideas?

Thanks
 
W

Wendy S

6e said:
I have created a simple servlet (that compiles properly) and compiled
it into a war file. I deployed the war file in the webapps directory,
and it is extracted appropriatly into a directory listed as

webapps/myapp/myapp.class

however when I browse to "host:8080/myapp/" all I get is a directory
listing. I tried to add a web.xml file, however it does not show up in
the listing, even after stopping and starting the service.

There is a very specific directory structure that you must follow, or things
won't work. The final word on this is the Servlet Specification, which you
can get here: http://java.sun.com/products/servlet/download.html If you're
going to develop web applications, you should at least skim this document
and look at the table of contents. For a long time I thought the
specification would be too technical and way over my head, and while some of
them are, (the JDO spec!) this one is fairly easy to understand.

Classes go under WEB-INF/classes, in a directory structure that exactly
matches the package name. And there needs to be a package name, the default
package has no place in a J2EE webapp.

If packaging the class and putting it where it belongs doesn't work, then
look at the log files (or the console, depending.) If you're still stuck,
post the error messages that appear on the screen or in the log, and seeing
your web.xml would also help.

Good luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top