Tag Archives: httprequest

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.

Advertisements