0

I know this question is similar to my previous question. I am making a AJAX request sending form values to a servlet which processes and sends me a JSON object as string. I am want to use that JSON object in my custom tag. How do I achieve this ? If its not possible with AJAX, what other alternatives have I got which prevents user from page refresh.

Community
  • 1
  • 1
Prabhat
  • 2,261
  • 7
  • 46
  • 74

1 Answers1

0

Custom tags are evaluated server-side, while ajax-requests are initiated from the browser. So you can't get a response from the server and use it in the tag evaluation.

Either add some javascript to the tag output which will handle the ajax response, or don't use JSON at all - since the tag is handled on the server you can get what you want without any serialization.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • Thanks for the reply. I have divided the pages into divs. So there is one page and the form is in one div, when I click submit, I am hiding this div and displaying some other div. When I click submit, it must go to the servlet and send an object. Earlier I was not using AJAX and I was able to send this object back by using request.setAttribute() and response.forward(). But this causes refresh in page, which I want to avoid. – Prabhat May 30 '11 at 12:03