File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes servlet and 404 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet and 404" Watch "servlet and 404" New topic
Author

servlet and 404

F. Corsini
Greenhorn

Joined: Dec 05, 2007
Posts: 10
hey guys

I keep getting a 404 error

I include everything possible for you to help me troubleshoot this, files screenshots and web.xml so it'll hopefully be easy for you, I'm reapproaching java after some time and I always make some mistakes with project structures

I've tried in eclipse and netbeans, with the same result ( failure )

as you can see it's a very very basic thing but I can't get it to work...

here's the project structure screenshot


this is my web.xml file

I can access the index.jsp page at http://localhost:8080/rsstest/web/
this page has a form that sends me to the servlet located at /Getfeed
the form is just a placeholder for something else, I need to get the servlet working before going ahead...
here's the code of index.jsp

[ December 05, 2007: Message edited by: Ulf Dittmer ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

It looks like you've got the JSP in a sub directory and are trying to call the servlet with a relative link.

Try:


For more information on creating links that are relative to the root of the webapp, see:
http://faq.javaranch.com/java/RelativeLinks


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
F. Corsini
Greenhorn

Joined: Dec 05, 2007
Posts: 10
thanks for the reply
I'm still getting a 404, now the message is The requested resource (/rsstest/Getfeed) is not available.

before the message was The requested resource (/rsstest/web/Getfeed) is not available.

I have the jsp inside a directory called "web", eclipse creates projects this way by default and I don't get it.

I had a look at the sample you have in your sign, it works and it has really simple structure, eclipse won't let me create such a simple thing (see the screenshot for what eclipse makes when I create a project)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
The important part of Ben's post was the changed "action" form attribute (and the RelativeLinks link for way of explanation). Did you implement it this way? What does the HTML of the form tag look like now?


Ping & DNS - updated with new look and Ping home screen widget
F. Corsini
Greenhorn

Joined: Dec 05, 2007
Posts: 10
it's action="${pageContext.request.contextPath}/Getfeed" that becomes action="/rsstest/Getfeed" when I access the page
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by F. Corsini:
I had a look at the sample you have in your sign, it works and it has really simple structure, eclipse won't let me create such a simple thing (see the screenshot for what eclipse makes when I create a project)


But did you read the FAQ entry at this link?
http://faq.javaranch.com/java/RelativeLinks
F. Corsini
Greenhorn

Joined: Dec 05, 2007
Posts: 10
I did and still don't see what I'm doing wrong

do you see any errors there guys? I can't really get what's wrong...
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Can you post the form tag as it is now?

Also, where, exactly is the class file for your servlet?
F. Corsini
Greenhorn

Joined: Dec 05, 2007
Posts: 10
here it is
<form action="${pageContext.request.contextPath}/Getfeed" method="post">First Name: <input
type="text" name="firstName" size="20"><br />
Surname: <input type="text" name="surname" size="20"><br />
<br />
<input type="submit" value="Submit"></form>

thanks your help guys
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

This looks OK.
Where is the class file?

Also, have you checked the container logs to see if anything is blowing up?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

This looks OK.
Where is the class file?

Also, have you checked the container logs to see if anything is blowing up?
F. Corsini
Greenhorn

Joined: Dec 05, 2007
Posts: 10
here's a screenshot of the current structure

I copied the class files also into WEB-INF/classes/stuff (stuff is the package name) because I saw you have done it this way in your example

what do you mean with the container? tomcat log?
here's the tomcat log for localhost (if other logs can help just ask)
F. Corsini
Greenhorn

Joined: Dec 05, 2007
Posts: 10
hey, it looks like I solved the problem restarting from 0

I followed this screencast http://keyboardsamurais.de/wp-content/uploads/2007/02/eclipse-wtp-tutorial.htm

it's the basic creation of a servlet in eclipse but it includes the configuration of eclipse, integration of tomcat etc

basically there's no difference from what I previously had, but the servlet is working now so probably there was some configuration error

with this easy to follow guide I'm sure most of those experiencing problems with servlet configation will be able to get them to work

it's not so easy to configure eclipse and tomcat at the beginning, this guy explains everything clarely

thanks for your help guys
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet and 404
 
Similar Threads
Error pages
error for first web application : The requested resource (/Beer-v1/SelectBeer.do) is not available.
Apache + Tomcat + JSF? ***newbee
Prevent intermediate access to any jsp page
The requested resource (/welcome) is not available." HTTP Status 404 - /welcome