• Post Reply Bookmark Topic Watch Topic
  • New Topic

using "Professional Java Servltes 2.3"

 
tom mcmorrow
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone out there who is using "Professional Java Servlets 2.3" from Wrox, if so did you have a problem when running the first example as setup on page 55 - I can get it to work if i set it up in my ROOT directory but not in servletAPI as he suggests. I have the TOMCAT 4 server configured as suggested in the Jakarta tomcat literature - i think. thanking you
tom
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For those of us that don't have the book, can you give us a few details?
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tom,
If the example works under the ROOT directory then it sounds like you're having problems with configuration/deployment.
What does your servletAPI directory look like, and did you restart Tomcat after creating the servletAPI "web application"?
Simon
 
tom mcmorrow
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi mike & simon
sorry for the delay in replying to your postings but i was away for the weekend. here is my setup for Tomcat server.I have
c:\
jakarta_tomcat_4.0\
webapps\
ROOT\
WEB-INF\
classes\
basicServlets\
BasicServlet
the url I use is - http://localhost:8080/servlet/basicServlets.BasicServlet
Like this it works.
However i feel from the instructions in the book i should have.
c:\
jakarta_tomcat_4.0\
webapps\
ServletAPI\
WEB-INF\
classes\
basicServlets\
BasicServlet
using the following url -
http://localhost:8080/ServletAPI/servlet/basicServlets.BasicServlet
however it doesnt work.

i think the servlet directory must be somehow used by the server but it does not appear in the drectory tree anywhere.
i hope the directory tree is comprehendable when HTML gets through with it
Thanking you for your help.
tom
[ April 28, 2002: Message edited by: tom mcmorrow ]
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's the 'quick and easy' way to deploy servlets, which is the approach taken in your book.

In short, when Tomcat receives '/servlet/' in any request, it invokes a class that goes and finds the appropriate servlet. This is work that it wouldn't have to do though, if you provided your own, more portable mappings.

As a very quick example for mappings,
Now if I define those entries inside my web.xml in the ServletAPI/WEB-INF directory, then
http://localhost:8080/ServletAPI/foo should invoke the servlet com.my.bar.foo

Doing it this way has the added advantage of 'hiding' your packaging and class name. (I can choose anything I want for "servlet-name" and "url-pattern")

For more info on how Tomcat does the magic with /servlet, open up <CATALINA_HOME>/conf/web.xml This file is heavily commented. Pay attention to the built in servlet definitions (the invoker starts around line 60) and the mappings (starting around line 234)

This file is very instructive both for how Tomcat provides the /servlet mapping service, and for how you should build your own web.xml
[ April 28, 2002: Message edited by: Mike Curwen ]
 
tom mcmorrow
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi mike
By careful application of the logic outlined by you above i seem to have overcome my difficulties.
Thanking you
tom
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!