How Can I generate a file in RemoteServiceServlet and send it to a user?
Maybe I can disable RemoteServic开发者_StackOverflow社区eServlet response serialization or define RemoteService interface with method that returns ServletOutputStram? I would like not to save request in any database to file to process it in another request.
If you want to provide a download to the user, you can do it like this:
- Write another servlet which simply writes out the file content through the ServletResponse
- Make sure you have a binary header and provide the filename in there, too.
- In your client, make an
<iframe ..>
(The widget class for this isFrame
) and point its url to your new servlet.
Due to the binary header your browser will now provide the user with a Save as.. popup. That should be all.
精彩评论