• 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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Struts2: Accessing a request Parameter from Action

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using traditional Ajax and passing a hidden parameter to the Action, but when i try to retrieve this parameter value, it returns null.
What could be the reason for this?

Following code list the Ajax calling mechanism




When I try to retrieve the value for 'hdnLicenseNumber' it returns Null.

Thanks.
 
Sheriff
Posts: 9709
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you are trying to do will not work. The AJAX request will not take any form values in the request. You might add the request parameter in the request URL like

 
Abdul Mujeeb Md
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ankit,

This works.
 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to get the request sent by ajax call in the action class?

I have written the below code:



but, on call of ajax function, nether setServletRequest nor execute method is getting called.

below is my ajax function in welcome.jsp file:



please let me know, where i am going wrong. thank you
 
Abdul Mujeeb Md
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Try to get the request Object this way:



Add this code in your Action.

Hope this works

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You haven't included any configuration information, so it's impossible to help.

Are you really not using a JavaScript library to handle the Ajax stuff? It's sooooo much easier and cleaner.
 
Abdul Mujeeb Md
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,

I haven't explored on it yet. Will catch on it soon.

 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Newton,

i am not using any JavaScript library to handle the Ajax stuff. i just follow w3school site tutorial. please help me.

Abdul Mujeeb Md wrote:
Try to get the request Object this way:





i can try it. but first either setServletRequest or execute method should get call. in my case, action class is not getting called on sending request from the ajax method.

please help.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:You haven't included any configuration information, so it's impossible to help.

 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi newton,

please find below my configuration files:

struts.xml




web.xml

 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
newton,

had i provided all the required configuration infos? or something is missing. please tell me.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And the app context is "Simple"? If so, it's not immediately obvious to me what's wrong.

Try using the config-browser plugin to see what S2 thinks your configuration is, and turn up logging to see if there are any startup issues or errors during the request processing.
 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
on the tomcat console, below warning is coming:

WARNING: No configuration found for the specified action: 'HelloWorld.action' in
namespace: '/'. Form action defaulting to 'action' attribute's literal value.

but my HelloWorld action class is called and return SUCCESS. then opening welcome.jsp page. HelloWorld action class is not getting called from ajax function only.

if ajax is not able to call the action class because of above warning then how could i fix this warning.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic