views:

56

answers:

1

I have a JSP program that displays a form where the user enters some criteria for a report. If the criteria fail validations -- missing fields, invalid dates, etc -- I want to redisplay the form with an error message. If the criteria pass, I want to display the report. But I want the report to be in a different tab or window, like if there was a target= parameter on it. Is there any way to do this?

I have the JSP written to submit the form back to itself for validation. If the validations pass, it creates a RequestDispatcher for the module that produces the report and forwards to it. If the validations fail, if displays the error message and then falls through to re-display the form.

I'm thinking that I want a way for the RequestDispatcher to force the display to a new browser tab. But I suppose that's making assumptions about the solution. Maybe there's another way to do it. The key requirement is just that if validations fail I want to stay on the same tab but if they succeed I want to go to a new tab.

A: 

You could certainly emit some JavaScript in your response, which causes some URL to open in a new window, where the URL contains a token for retrieving the report data.

Jonathan Feinberg