Struts 2: how to set response for ajax function call?
Ramesh Babu Essampalli
Greenhorn
Joined: Oct 19, 2009
Posts: 5
posted
0
i am calling an ajax function from jsp page. The execute method of action class is getting called.
now, i want to set response parameter in execute methood for xmlhttp.responseText in ajax function call. i implemented ServletResponseAware and in setServletResponse method i set response parameter. but the response param value is over-written by return page of execute method. please suggest me a way to set response param.
You must be talking about this piece of code. When your action sends the request to a JSP page, this content will be ignored. If you don't want to send the request to the JSP, then return null from the execute method. You can't send response from action and JSP both...
but was facing problem in returning values into response. that is now solved after returning null from the action class.
but now, i have another issue related to it.
i have a list of textfields in the jsp shown below:
i have added mylist variable into my action class. and adding a value to mylist on ajaxcall. please refer my modified action class below:
but the change in value of mylist is not adding a textfield into the jsp page. please give me some direction to add the textfield dynamically using ajax. thanks.