This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes My servlet wont work: Simple answer i expect! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "My servlet wont work: Simple answer i expect!" Watch "My servlet wont work: Simple answer i expect!" New topic
Author

My servlet wont work: Simple answer i expect!

Thomas Richards
Greenhorn

Joined: Mar 20, 2005
Posts: 7
Ok i have my class file i have the directory structure as follows :

tomcat-

webapps
profit
WEB-INF (including my index.html)
classes(including my web.xml)
Profit.class
lib

So my three files index.html, web.xml and Profit.class are all there and i belive to be in the correct place.

If they are in the correct place i expect the answer lies within my xml file: Would this be correct.

<web-app>
<servlet>
<servlet-name>Profit</servlet-name>
<servlet-class>Profit.class</servlet-class>
</servlet>

<servlet-mapping>
<url-pattern>/profit</url-pattern>
<servlet-name>Profit</servlet-name>
</servlet-mapping>
</web-app>

If you need anymore info please done hesitate to ask.

Thanks in advance!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Files under WEB-INF are hidden from browsers.
You shouldn't put the ".class" extension on the filename in the servlet-class attribute.

Download and run SimpleServlet from http://simple.souther.us for an example of a properly laid out "Hello, World" servlet app.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

And be aware that the servlet must be in a package other than the default.
[ March 20, 2005: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

"Hugogo",
We're pleased to have you here with us in the Servlets forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Thomas Richards
Greenhorn

Joined: Mar 20, 2005
Posts: 7
Thanks done
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My servlet wont work: Simple answer i expect!