This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes HFSJ - The first servlet - I can't get it to work (SOLVED) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HFSJ - The first servlet - I can Watch "HFSJ - The first servlet - I can New topic
Author

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

Steven Satelle
Greenhorn

Joined: Sep 30, 2008
Posts: 22
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:

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

-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 :)
Virendrasinh Gohil
Ranch Hand

Joined: Jun 09, 2004
Posts: 46
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

Joined: Sep 30, 2008
Posts: 22
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

Joined: Sep 30, 2008
Posts: 22
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 :-)
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

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.


Love all, trust a few, do wrong to none.
 
jQuery in Action, 2nd edition
 
subject: HFSJ - The first servlet - I can't get it to work (SOLVED)
 
Similar Threads
404 Error
Newbie problem from chapter1 of Head First Servlets & JSP
1st servlet example
HTTP Status 404 - /ch1/Serv1/
Error 404 while requesting for a page