Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Requested Resource Not Found Error

 
Michael Eller
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here I will go ahead and post the code for the two files:

index.jsp



And the SaveForm.java file:

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We still don;t know what your folder structure looks like. Use code tags to maintain formatting and indentation.
 
Michael Eller
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you submitting to? *That's* what the error is. You can't submit to a simple POJO.
 
Michael Eller
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 32
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 12617
    IntelliJ IDE Ruby
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Good deal--while taking a step back can seem counter-productive, you'll be happier (and much smarter ;) in the long run :)
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic