aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes 404/resourse not availabel elicpse-tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "404/resourse not availabel elicpse-tomcat" Watch "404/resourse not availabel elicpse-tomcat" New topic
Author

404/resourse not availabel elicpse-tomcat

Benjamin Madore
Greenhorn

Joined: Jan 24, 2012
Posts: 11

I'm trying to follow the tutorials is the O'Rielly Java Servlet Programming book, but I can't get the example to work. I put a jsp in web-inf and it appeared. (Tomcat 7.0.53)

The servlet:


The web.xml:


I've tried removing "servlet" from the path, but I still get the 404 "The requested resource is not available."

I imagine it's something obvious, but there's a bit of a gap in the book I have and what I'm running on.

I can get a jsp page to show, so I'm relatively certain I have everything correct. I just press the "run" button and select Tomcat.


Linguistics Department server/application manager & programmer.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

It's WEB-INF, not web-inf.

And why have you mapped /* to your servlet?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Benjamin Madore
Greenhorn

Joined: Jan 24, 2012
Posts: 11

Bear Bibeault wrote:It's WEB-INF, not web-inf.

And why have you mapped /* to your servlet?


Sorry, yes, capitalization matters in some places.

I mapped /* in an effort to get any response from the servlet.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

Remove the mapping as it'll cause more problems than sole any.

Have you gone through the steps in the ServletsFaq?
Benjamin Madore
Greenhorn

Joined: Jan 24, 2012
Posts: 11

Ok, I'm looking at the FAQ. (I was previously maintaining older code, and I have come from a mostly php, C and C++ background.) This is my first from scratch servlet.

I think I don't have a package. I just ran the wizard in eclipse and put my code in it, and my .java file sits in the "src" folder and not a sub folder. It would have to sit in a sub folder and have a package keyword? The wizard didn't do that.



I would have to change all that and then point the web.xml file to something other than:


I would make it something like "IntDestroyCounter.<new package>.init" so the class and path match up as well. Then put a folder in for the new package, and put "package init" at the top of init.java.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

In my opinion, letting a wizard generate your code isn't doing you any favors. Use the IDE as a smart editor, but write all the code yourself.

And yes, servlets, along with all other classes in a web app, must be in a package. But no, the InitDestroyCounter would not be part of the package. The package hierarchy would be rooted at src, and must be mirrored in WEB-INF/classes.

If you are not familiar with Java packages, that's a core concept you need to understand before writing web apps.
Benjamin Madore
Greenhorn

Joined: Jan 24, 2012
Posts: 11

I'm trying to figure this out, to get my "hello world" example going with the intention of teaching myself. I have added "package test;" to my source and tried changing my web.xml to:


I created a directory and now the source is at: src/test/init.java

I'm seeing init.class under build/classes/test

when I go to http://localhost:8080/InitDestoryCounter/init I'm still getting "The requested resource is not available"
Benjamin Madore
Greenhorn

Joined: Jan 24, 2012
Posts: 11

I also tried importing a pre-made project from http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html in "test-app.zip" and I get the same error.

I tried cleaning, deleting and rebooting things... I think it worked.
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 999
    
  13

Benjamin Madore wrote:


Don't do empty catch blocks. Ever. It's only a matter of time before that bites you in the butt. You'll find that even just printing the stacktrace will give you a clue that would help you track down the error, without which you'll spend hours scratching your head.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Benjamin Madore
Greenhorn

Joined: Jan 24, 2012
Posts: 11

Thanks all!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 404/resourse not availabel elicpse-tomcat