• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Cannot get Ch3 Example of Head First Servlets to Work  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone. This is really frustrating! Id rather just move on with the book but I cant read it without trying to figure out how to get this to work. Everything works fine until I try to add in the servlet portion. When I hit the submit button on the HTML form I get this :

Also, Im running this on windows xp




Here is my web.xml, my html and my java:







And the directory structure for webapp is exactly what the book shows (im kinda winging this diagram below




It seems like I have everything set up correctly. Does anyone see anything I missed? Also, there very well could be some sort of problem with the compilation of BeerSelect.java as Im not sure I have everything configured as far as paths and everything because im a noob at setting this stuff up on my own computer. I was able to get it to compile with no warnings or errors though.... I also am behind 2 routers, I dont know if that would cause a problem though.

Please help! Im supposed to be absorbing as much of the main points of this book as I can for a job interview on tuesday but I cant stand to read it until I can get this example to work!!! =( Thanks everyone

oh and edit: this was the command I used to compile:

from:

C:\Documents and Settings\Brian\Desktop\My Projects\beerV1

javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar";classes; -d classes "C:\Documents and Settings\Brian\Desktop\My Projects\beerV1\src\com\example\web\BeerSelect.java"
 
Mike Love
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to redo this all in Netbeans with the same exact files. Once I changed the XML file to look like:



it worked running it from netbeans. Although it was still throwing some errors in the log, I was able to access the html and hit the submit button and have it run the servlet and display my choice. I tried copying that xml file back to my tomcat directory and running the tomcat server again, but I was still getting the same 404 error as mentioned above. So, it looks like the code was all fine (except for possibly the xml?). I have no idea why it doesnt work when trying to start tomcat directly like the book says. Any ideas?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had the same problem with a 404 but fixed it by renaming Beer-V1 to just beer. Then it worked. Odd.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Christian Llennoc wrote:I had the same problem with a 404 but fixed it by renaming Beer-V1 to just beer. Then it worked. Odd.



I just did this and it actually works. Anyone know of a reason for this?

Edit: Sorry for bringing up a thread a few months old, but this had been bugging me for a while.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!