• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Cannot retrieve mapping for action

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to get some sample struts code I got off the web to run.
I am using the resin webserver. I copied the struts-blank.war over. bounced resin. renamed it to 'myproject'.

I am getting:



The instructions say to put this jsp in the top level directory under myproject.




Here is my struts-config.xml. it is in myproject/WEB-INF


here is the web.xml the tutorial said to use

 
Ryan G Johnson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry for the double post. I put this in JSP forum also. I just noticed the struts forum.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Change

<html:form action="submit.do">

to

<html:form action="submit">

in your JSP.
 
Ryan G Johnson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when do you use .do ?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you're specifying an action attribute inside a struts tag, as with <html:form> struts already knows you're referring to a Struts Action, so you don't want to append .do in this case.

When you call an action from the browser's URL line or from a non-struts tag, you're passing a URI to the App server that must be translated to a Struts action. The .do causes the URI to get referred to the struts ActionServlet where it can then call the appropriate Struts Action.

The answer to your question, then, is that you use the .do when calling an action from the URL line in the browser, or from a non-struts tag such as <a href="">.
[ January 19, 2006: Message edited by: Merrill Higginson ]
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it should work with "submit.do" too.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make sure your SubmitAction class extends Action. Can we see your Action class?
 
Ryan G Johnson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i get the exact same error when i remove .do
 
Ryan G Johnson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is my submitAction class



submitForm

 
Ryan G Johnson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
could it have something to do with not being able to find my struts-config.xml? I did copy the struts-blank.war file and rename it.

C:\resin-2.1.11\webapps\myproject\WEB-INF\struts-config.xml
 
Ryan G Johnson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my jsp after merrill's changes.

 
Ryan G Johnson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i bounced the webserver and now it works.
 
Ryan G Johnson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill-- you said that the .do made struts look for my action class?

I have a submitAction.class file in: C:\resin-2.1.11\webapps\myproject\WEB-INF\classes\hansen\playground

is my mapping setup wrong in my struts-config.xml ?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I'm trying to get across is that passing a URI that ends in .do to the App Server causes the struts ActionServlet to be invoked. Here is the code in web.xml that makes this happen:



Once inside the Struts ActionServlet, Struts will then use the rest of the URI to determine which Action class to invoke. It does this by comparing the URI to the Action Mappings you've defined in struts-config.xml.

It's different, though, when you're using a Struts custom tag, such as <html:form>. The action atribute of this tag is expecting a Struts action mapping exactly as you have defined it in struts-config.xml. There is no action mapping for "/submit.do" in your xml file, and that's why it didn't work.

The principle here is that you use /myAction.do when passing a url in from the browser or from a link, and you use /myAction inside a Struts custom tag such as <html:form>

I'm a bit confused, though. You said it's working, right? If it's working, that means you set up your struts-config.xml file properly.
[ January 20, 2006: Message edited by: Merrill Higginson ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic