Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My servlet wont work: Simple answer i expect!

 
Thomas Richards
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And be aware that the servlet must be in a package other than the default.
[ March 20, 2005: Message edited by: Bear Bibeault ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
Thomas Richards
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks done
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic