rgamber
rgamber

Reputation: 5849

Reload a frame after a form submit

I have a situation where I have a A.jsp, which has an <iframe> with source B.jsp. There is a form in A.jsp, which when submitted should ideally reload only the <iframe>. If I do a response.sendRedirect("B.jsp"), obviously the entire A.jsp page is redirected to B.jsp. I don't want to reload A.jsp. How can this be done?

Upvotes: 0

Views: 2120

Answers (1)

BalusC
BalusC

Reputation: 1109570

Set the form submit target to the iframe's ID.

<form ... target="results">
    ...
</form>

<iframe id="results" ...></iframe>

This way the response of the form submit request will end up in that iframe.


Needless to say that this is a poor practice whenever both content originate from the same domain. Consider server-side includes like <jsp:include>. That's way much better for user experience and SEO. If necessary you can always bring in some jQuery to do the asynchronous magic.

Upvotes: 2

Related Questions