Monday, May 28, 2012

Re: GWT and HttpServletResponse


On Monday, May 28, 2012 5:26:57 PM UTC+2, Akis wrote:
Hi guys. I've got a question for you:

i need to create a web app which, starting from an input string given
by the user through the browser, generates a file that has to be
downloaded by the user self.

My approach would  be the following: the input string is sent by a RPC
to a server-side class that creates the file from the given string,
and then the file is sent to the client-side, ready to be downloaded.

Now, in "classic servlet way", i would use a HttpServetResponse to set
the header, the content type, and attach the file... how can i do this
with GWT?

"With GWT", yes; but not with GWT-RPC (just like you couldn't do it with SOAP WebServices // granted, you can use a SOAP extension to attach files to SOAP messages, but still).

Either you use GWT-RPC and then the server has to generate the file on a temporary storage (could be in-memory / in-session) and sends an URL back to the client, and then the client can download that file at the given URL.
Or you use a FormPanel to communicate with the server.

The first method works best if the generated file could be displayed in the browser (right away or using a plugin; such as plain text, PDF, MS Word, etc.), so I'd recommend it over the FormPanel, despite being more complex (temporary storage has to be cleaned-up, otherwise it's not temporary)

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/HcI32qldhh0J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment