Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Response content type  RSS feed

 
arunseege paramashivappa
Ranch Hand
Posts: 33
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hell javaranch,i am stuch with one issue.This issue is regarding response from the servlet

I have written a code to download .csv file with records from DB.

To download records i am uploading a .CSV file containing telephone number.

After downloading the .CSV file page is not getting refreshed.

Below is the code snippet i am using,where i am setting response content type as test/csv.

ServletOutputStream op = resp.getOutputStream();
// Set content type of output
resp.setContentType("text/csv");
resp.setHeader("Content-Disposition", "attachment; filename=\"test\"");
op.flush();
op.close();

Please help me to resolve this issue so that page will get refreshed after csv file download or after response.

Thanks-Arun
 
E Armitage
Rancher
Posts: 989
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no way to refresh the page after the download is complete except by firing another client request.
Some libraries/frameworks provide polling options (e.g primefaces p:poll) which you could try if you really need this feature.
 
arunseege paramashivappa
Ranch Hand
Posts: 33
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.

Actually i will use XSLT at presentation tier.
 
arunseege paramashivappa
Ranch Hand
Posts: 33
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello javaranch,is there anyway we can say sendredirect()
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot send a redirect after the response has been committed to the output. As mentioned above you need a fresh request typically an AJAX call to refresh the page, if needed.
 
arunseege paramashivappa
Ranch Hand
Posts: 33
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all.It was helpful
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!