Forums Register Login

Assign response text from AJAX to a JSP tag attribute

+Pie Number of slices to send: Send
I am using AJAX to get a string which I want to assign to a String attribute in custom JSP tag. For example,


Is there any direct or indirect way to achieve this ?
+Pie Number of slices to send: Send
There is no way to achieve that. The JSP executes on the server, the Ajax request can;t be sent back to server until after the JSP finishes and the HTML page has been sent to the browser.

Please read this article to understand what JSP is and how it operates, and why what you are asking is impossible.
+Pie Number of slices to send: Send
P.S. If you need the result of a request while JSP is executing on the server, investigate the <c:import> tag.
+Pie Number of slices to send: Send
 

Bear Bibeault wrote:P.S. If you need the result of a request while JSP is executing on the server, investigate the <c:import> tag.



Yes. This will do. I went through <import> tag description. But how do I use the result of AJAX (xmlhttp.responseText) in the imported page Must I use something like this ?


How do I assign javascript value to c:param 's value ?
+Pie Number of slices to send: Send
If you use <c:import> you won't be using Ajax.
+Pie Number of slices to send: Send
 

Bear Bibeault wrote:If you use <c:import> you won't be using Ajax.



Actually, 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. Is it possible to use c:import instead ?
+Pie Number of slices to send: Send
<c:import> will simply grab whatever the response is. If it's JSON, then that's what you'll get.

At this point, just try it out.
+Pie Number of slices to send: Send
 

Bear Bibeault wrote:<c:import> will simply grab whatever the response is. If it's JSON, then that's what you'll get.

At this point, just try it out.



Thanks for helping me out so far.
I understand how it works. But the point is I need to send elements from the form to the servlet.

The flow looks like this

First I contact servlet.


The above code will return me a JSON string. I need to use this JSON string and send it as parameter to my page like this



Please let me know how ?
a wee bit from the empire
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2757 times.
Similar Threads
using expressions of JSP in struts tag
Tag Files : Tag Attributes Doubt !!!
Confirmation required
having problems with javascript
JSP to EL conversion
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:07:50.