Ajax and JSP

S

Sahil Dave

Hi there

I am using Struts 1.3 for a web app.
One of the JSPs that I am creating has a requirement wherein a multi-
select box and a textbox needs to be dynamically filled with values
upon selection of some value in a dropdown (ofcourse using an Ajax
call).

I am not really sure if there is a well-defined way of doing this in
Struts. I plan on using JQuery for the JS part.
Any suggestions/pointers would be really helpful.

Thanks
S Dave
 
T

Tim Slattery

Sahil Dave said:
Hi there

I am using Struts 1.3 for a web app.
One of the JSPs that I am creating has a requirement wherein a multi-
select box and a textbox needs to be dynamically filled with values
upon selection of some value in a dropdown (ofcourse using an Ajax
call).

I've done something similar to that. Selecting a value in a drop-down
triggers an AJAX call that populates a text box. The AJAX call is to a
Struts Action object, that works normally except for two things:

First, it writes its output directly, instead of saving an object in
request context. Second, it returns null instead of an ActionForward.
The last few lines of the "execute" method look like this:

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println(message);
out.flush();

return null;

I am not really sure if there is a well-defined way of doing this in
Struts.

Dunno how well-defined it is, but it works just fine. Post again if
you need more details.
 
A

Arne Vajhøj

I am using Struts 1.3 for a web app.
One of the JSPs that I am creating has a requirement wherein a multi-
select box and a textbox needs to be dynamically filled with values
upon selection of some value in a dropdown (ofcourse using an Ajax
call).

I am not really sure if there is a well-defined way of doing this in
Struts. I plan on using JQuery for the JS part.
Any suggestions/pointers would be really helpful.

I would consider it tempting to have the AJAX requests
be processed outside of Struts.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,113
Latest member
Vinay KumarNevatia
Top