• 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

Downloading file

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

I am developing a servlet, which will send user a file and also a successful page by clicking on a single button on a page.

I have no problem with sending user a file...... but i don't know why I could never send the successful page across, there is no error and it seems the browser just ignore the successful page........ Here is my questions.

1. Does http allows 2 responses for a single request?
2. Can I send 2 responses with the same response object?

Thanks for any help.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No and no.

If you'd give further details of the scenario, we can make some suggestions.
 
John Ip
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a page and in it I have a button "Export" for the user to click on, when they want a soft copy of their details (a plain txt file with all the user details). And then show a message " export successfully " on the window.

HttpServletRequest req = context.getRequest();
HttpServletResponse res = context.getResponse();

res = context.getResponse();
res.setHeader("Content-disposition","attachment; filename=user.txt");
ServletOutputStream out = res.getOutputStream();
out.write(UserBean.getInfo(user).getBytes());
out.flush();

res2 = context.getResponse();
// return the successful page here
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic