This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in struts DispatchAction

 
vipul bondugula
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

I am having problem with struts dispatch action.
In my form action, iam concatenating action path with additional parameter and using method as GET..
when i submit, the additional parameter is not going and my form parameters are going..

But using POST, I am able to send the additional parameter also..

can anyone tell me y this is happening?

Thanks in Advance,
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi vipul,

Can you please put some code you are trying?
 
vipul bondugula
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply shailesh.

This is the form iam using. I am concatenating a string with the action attribute path,i.e.DispatchAction Method.
<form action="setValues.do?method=execute" method="get">
First Name:<input type="text" name="t1" value=""/>
Last Name:<input type="text" name="t1" value=""/>
Middle Name:<input type="submit" value="submit"/>
</form>

my struts-config.xml file
<struts-config>
<form-beans>
<form-bean name="myPath" type="com.spry.forms.ValueFB"/>
</form-beans>
<action-mappings>
<action name="myPath" path="/setValues" type="com.spry.actions.ValueDispatchAction" parameter="method"/>
</action-mappings>
</struts-config>

when i use method="get", i am getting dispatch action method not found..
but this problem resolved,when i used method="post"..

Actually what i need to know is the reason why the dispatch action method not found when i used method="get".

Please tell me..

Thanks in Advance,
 
vipul bondugula
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any one please reply to the post..!
 
Vicky Vijay
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vipul,

which verion of struts you are using ?

Try using the Struts based tags..

html:form, html:text... etc



 
vipul bondugula
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using struts 1.2..
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vipul,
There should not be any problem, could you please post the complete exception stack trace. Also verify the "security-constraint" specification in your deployment descriptor.

 
vipul bondugula
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



my form is



work on this sample form.....copy to to your html page...write a dispatch action with method "doWork" in it. configure doWork in struts-config.xml file...An ActionForm..

work on it ..You will be getting above stack trace...

For post form is working as expected..

I just want to know the reason..Already i am working on it..any suggestions are acceptable...

Thanks
BVR
 
vipul bondugula
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I debugged into RequestProcessor class.

In processActionPerform() which takes request, response, action, form, mapping as arguments DispatchAction execute() is called. In that method,

from mapping object got the parameter.



if mapping object is not there then response.sendError is done..

I got my paramter object as method.
when retrieving method value i am getting null..




here name , iam getting null value


This happens for form method="get" request only..

For Post request it is working fine...

Please tell me what is happening with get and post requests in DispatchAction...

i mean to say is





with get and post as method values and DispatchAction as the page controller.....
 
vipul bondugula
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After debugging into more, i found why the method value is not coming.

we assosciated method="doWork" as queryparameter to the form action..when we click on submit browser is creating its query parameter removing what we assosciated.

for the post it is working . here browser is adding form parameters to the body not to the url..for the post DispatchAction is not creating any problem..
For get problem is coming...

Why browser is removing the query parameter what we have attached..?
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vipul, no tools to set it up
I am still sure about dispatch action, that it doesnt do something like that.
But after looking couple of times into the code posted, i realized that you are not using html:form. Just let us know if the result changes after using struts-html tag. I am expecting the same result - it should fail
If i remember properly, if the html form submission is of type GET, then it would take the 'action' mentioned and append '?' followed by appending the form data [anybody please correct me if I am wrong]
So the above submission would be something like 'doWork.do?method=doWork?&first=something'. Now if we give something like this to struts, I do not know how it would behave - we have to look into the implementation.
Since you already have a debug environment could you please check and see [by retrieving HttpServletRequest.getRequestURL()] if my understanding is correct/wrong.

Thank you in advance
 
vipul bondugula
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shankar Tanikella wrote:
If i remember properly, if the html form submission is of type GET, then it would take the 'action' mentioned and append '?' followed by appending the form data [anybody please correct me if I am wrong]
So the above submission would be something like 'doWork.do?method=doWork?&first=something'


You are right shankar.

More over we no need to check the reqeust object. we can see the url in the browser address bar. As the request is a GET request you can see the whole query parameter in the address bar. there you won't find method=doWork parameter. Remaining form parameters will be available.




 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good, so that answers our doubt
 
vipul bondugula
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YES..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic