• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

HFSJ - The first servlet - I can't get it to work (SOLVED)

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm working through the Head First Servlets and JSP's (send ed.) book and I can't get the first servlet to work. Despite trying things I found in other threads on this forum for the same thing
I'm getting a 404 error when I go to the url http://localhost:8080/ch1/serv1

message /ch1/serv1

description The requested resource (/ch1/serv1) is not available.



Can anyone give me a pointer to what (undoubtedly stupid) mistake I'm making?

My system details:
OS: Ubuntu 10.0.4 (32 bit)
Tomcat Version: Apache Tomcat/6.0.24
JVM Version: 1.6.0_18-b18
JVM Vendor: Sun Microsystems Inc.
OS Name: Linux
OS Version: 2.6.32-24-generic
OS Architecture: i386

My Servlet code:


My web.xml:


the project (project1) directory structure:


Finally, the webapps directory structure:

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
-C! -C! It's easier with the trailing "/" to show directories.

I would, however, like to commend you on the quantity and quality of information provided to help solve the problem.

Unfortunately, I'm not sure what the problem is, because everything appears to be in order. Is there anything in the log at startup or when you try to access the servlet from the browser? (And you're probably right, it'll end up being something silly, which will make *me* look even sillier for not seeing it :)
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree. Everything seems to be in place and hence really difficult to predict what's going on wrong. So, thought of asking very basic (and bad) question. Have you started/restarted tomcat after the deployment? [tomcat doesn't support hot-deploy].

If you have restarted the tomcat, can you please study the log and let us know whether everything is fine there? No exceptions?
 
Steven Satelle
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I restarted (if I hadn't, I'd take myself out back and shoot myself - as a mercy to the rest of the human race :-))

As for the logs .... de nada. Or I can't find them.
The only log in the web server showing changes is Catalina.out:

No mention of my app at all
 
Steven Satelle
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's fixed, and it's stupider than not restarting the app server

On Linux (well Ubuntu 10.0.4 anyway) you have 2 webapp directories /usr/share/tomcat6/webapps and /var/lib/tomcat6/webapps/
why? I don't know

I'd been using /usr/share/tomcat6/webapps. This is apparently the wrong one to use. I put my app into /var/lib/tomcat6/webapps, restarted and it worked

Thank you for the assistance, I'm afraid I now have to get a gun and drag myself out back, nice knowing you :-)
 
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Steven, in the beginning I also used to get the same errors. What I did in the beginning is, we wont get servlet.jar with jsdk, so I used to copy the jar into java/jre/lib to compile. Then later I used to take the class tile into WEB-INF/classes folder. Then later I realized that this is not the right approach, so you once check whether you have done something like this.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic