wood burning stoves 2.0*
The moose likes JSP and the fly likes Requested Resource Not Found Error 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 » JSP
Bookmark "Requested Resource Not Found Error" Watch "Requested Resource Not Found Error" New topic
Author

Requested Resource Not Found Error

Michael Eller
Ranch Hand

Joined: Feb 28, 2004
Posts: 32
Hi,

I have been searching through the archives for an answer to my problem...but I cannot find one that matches up to what I am seeing.

I have a .jsp page the uses a bean (not servlet)



On my tomcat5 server, I have a directory named budgettool. In that directory I have the index.jsp which has the code above.
Also in the budgettool directory, I have the WEB-INF directory which has sub directory classes which has sub directory budget.
Within that budget directory is my bean (SaveForm) called by the index.jsp. The SaveForm bean is in package budget.

The error message I get says the requested resource /budgettool/SaveForm is not available.

I am thinking I have some paths messed up...but another jsp page in the same location can call another bean in the same package without a problem...so I am confused.

Any ideas?

Thanks,
Mike
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm having a hard time visualizing the issue. Could you provide a nicely-formatted directory tree, and a better explanation of under what circumstances you see the error?
Michael Eller
Ranch Hand

Joined: Feb 28, 2004
Posts: 32
Directory tree on tomcat server

webapps
budgettool - index.jsp
WEB-INF
classes
budget - SaveForm.java, SaveForm.class


On the index.jsp page is a form


I want the form to use the SaveForm bean located in the budget directory from WEB-INF->classes-->budget

Does this help?
Do you want more?
I will post everything if needed.

Thanks,
Mike
Michael Eller
Ranch Hand

Joined: Feb 28, 2004
Posts: 32
Here I will go ahead and post the code for the two files:

index.jsp



And the SaveForm.java file:

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What are you submitting to? Is the servlet mapped? The error message indicates no--as far as I can tell this is a misunderstanding of how Java webapps work.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

We still don;t know what your folder structure looks like. Use code tags to maintain formatting and indentation.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Michael Eller
Ranch Hand

Joined: Feb 28, 2004
Posts: 32
Sorry,
Here is the structure....



And my understanding is (of course could be totally wrong) was that this is a bean and not a servlet...so it does not need the mapping as a servlet does???

Thanks,
Mike
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What are you submitting to? *That's* what the error is. You can't submit to a simple POJO.
Michael Eller
Ranch Hand

Joined: Feb 28, 2004
Posts: 32
I am not sure I understand the question.

I want to submit the form data via post to the SaveForm class.

v/r
Mike
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

Michael Eller wrote:I am not sure I understand the question.

I want to submit the form data via post to the SaveForm class.

You may want to, but you can't. You can submit to a servlet. The servlet can then create an instance of your POJO and capture the request parameters into it if it wishes.
Michael Eller
Ranch Hand

Joined: Feb 28, 2004
Posts: 32
Bear Bibeault wrote:
Michael Eller wrote:I am not sure I understand the question.

I want to submit the form data via post to the SaveForm class.

You may want to, but you can't. You can submit to a servlet. The servlet can then create an instance of your POJO and capture the request parameters into it if it wishes.


OK, so now I am confused. I have been looking at tutorials that do just what I am trying to do...without using servlet....but rather using java class with setter and getter functions.

And, I also tried the same action with servlet and got the same error message.
So either way I am doing something...not right!

Can someone point me to a tutorial that covers this...from end to end...to include the web.xml file and file structure and such?

Also, just for my learning, what is POJO?

v/r
Mike
Michael Eller
Ranch Hand

Joined: Feb 28, 2004
Posts: 32
So if I used a java class that extends the HttpServlet class and placed that in same file structure as the SaveForm class above, should that work?

What web.xml would be required and where would I place that file? In the WEB-INF? Is the WEB-INF in the right place?

Thanks,
Mike
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I think you should take a step back and brush up on some Java web app basics; there are a huge number of resources available on the web, including at Sun.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

The Tomcat documentation is a good place to start as well.

Some points to note:
  • Your WEB-INF must be in the root of the context folder.
  • Your web.xml must be in WEB-INF.
  • You must declare and map all of your servlets.
  • Classes must be in a package.
  • The package hierarchy must be placed in WEB-INF/classes (or get jarred and placed in WEB-INF/lib).
  • Michael Eller
    Ranch Hand

    Joined: Feb 28, 2004
    Posts: 32
    Thanks,

    I will take the advice from you both and step back a bit and do a little walking before I run!

    Thanks Guys!

    v/r
    Mike
    David Newton
    Author
    Rancher

    Joined: Sep 29, 2008
    Posts: 12617

    Good deal--while taking a step back can seem counter-productive, you'll be happier (and much smarter ;) in the long run :)
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Requested Resource Not Found Error
     
    Similar Threads
    Jsp not accessing bean class !
    Need help with jsp:useBean class not found
    Calling A Class From JSP
    JasperException from non-numeric parameter value
    Can an action class forward to another action class?