• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet Response content type

 
Ranch Hand
Posts: 33
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 989
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.

Actually i will use XSLT at presentation tier.
 
arunseege paramashivappa
Ranch Hand
Posts: 33
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello javaranch,is there anyway we can say sendredirect()
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all.It was helpful
reply
    Bookmark Topic Watch Topic
  • New Topic