This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
In my application there are several buttons in various pages which does the same functionality of downloading records into an excel file.
All requests for download go to Download.do?status=X where X varies. Now based on X the data present in the HttpSession object is filtered and is written into an excel.
If in case there is no data existing in the HttpSession object after filtering is applied then I was thinking about showing an alert box which will inform that there are no records to be downloaded.
I have written the below code to achieve that.
PrintWriter pw = new PrintWriter(response.getOutputStream());
"alert('There are no records to be downloaded')" +
But the problem with this is that, the screen which was previously available goes blank and only the alert pop-up is shown. I want the previous screen to be as it is and only the alert box to appear. As in case of an excel which comes as an attachment on setting the ContentDisposition header attribute in HttpServletResponse
can anyone please help me on how I will have to achieve this?
But my problem is various jsps call the same action Download.do. Each jsp needs a different set of data that has to be downloaded so I make use of a 'status' request parameter added to the query string (for eg. Download.do?status=E). The value of status varies.
So based on the status value when I don't get any records, I wante to return back an alert message which has to appear before all jsps and the screen state at the background shdn't change.
Still, I put my approach for the same if you want to do that,
what I thought of doing this is:
1. Get the incoming JSP page
2. Try to embed the "alert" JS tag into it (Its hard to do, have some Googling) OR simply append the JS
3. response output this new modified JSP
Isn't that hard ?
The best and standard way is always been the ActionMeassges in Struts.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Writing an alert into a HttpServletResponse object