java - Handle attachment in response with RequestBuilder in GWT -


I am making an HTTP post request from the GWT client in an HTTPServlet. This certificate is making a PDF file from the request content and writing it in the feedback stream.

The feedback streams are as follows:

  Content-Dispute: Attachments; File name = report.pdf   

I want to open this PDF in a new window in the user's browser or want to indicate it to download it.

  import com.google .gwt.http.client *. ... string url = "http://www.myserver.com/getData?type=3"; RequestBuilder Builder = New RequestBuilder (RequestBuilder.POST, URL.encode (url)); {Request request = builder.resendRequest (data, new request callback (error) {error on public void (request request, throbbing exception) {// server could not be connected (timeout, SOP violation, etc.)} Received liability on Public Zero (Request Request, Response Feedback) {If (200 == response.getStatusCode ()) // // Response process in response.getText () // // window.open (url, "_blank "," ");} And {// error handle. GetStatusText ()}}}); } (RequestException e) {// could not connect to the server}   

How can I respond to feedback on resizing?

I think that in this case you have to call a single RequestBuilder AJAX call Should not be used. You can rely on default browser behavior by turning on a normal call and the browser can handle the PDF response (can display with a PDF viewer plugin or open a save dialog).

There are several options to achieve this:

  1. If you have your data passed in a GET request (possible only for a small data volume) You can create a URL with data in the form of GAT parameter and then open a new browser window with the data passing the URL

  2. Large quantity For data you first need to store your data temporaly with RequestBuilder and a new one Can post open Raujhr window Alternatively a short URL 1 above. In the server side, you have to divide the PDT generation servlet into two parts: a data store servlet (i.e. submission of data in web session) with POST method and submission of servlet with a PDF GET method, which does not have data out of session (And it is being removed) and does not require large parameters.

  3. Method to post, hidden fields and PDF generation sublett urls for your data, fill the hidden fields with your data and submit the form according to the format (ie). If you create your FormPanel , the browser opens a new window or uses the specified frame to handle the feedback.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -