Dual request to a servlet

If you want to get back a mime – application/PDF or excel as a response and still redirect to a jsp page with a single button click, the. You can have two forms in the requesting page and then call a JavaScript function on-click on both these forms. Both the forms may have the single action that takes it to the same servlet. In JavaScript, do the document.form1.submit and do some arbitrary sleep and then do the document.form2.submit. In response, you will first get the PDF and then the redirection to the jsp. You need to give response.sendredirect on the servlet side for redirecting to the jsp.
Alternatively, this can be done using a target attribute in the form, eg. Target=abc.jsp and in the JavaScript submit function , use self.location.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s