Gwt RequestBuilder + Servlet issue

690 views
Skip to first unread message

Praveen Ramachandran

unread,
Sep 2, 2011, 8:40:59 AM9/2/11
to Google Web Toolkit, prave...@gmail.com


HI,

I am using a RequestBuilder object from Gwt to send a innerHtml string
from a panel to generate a PDF report in the servlet

SomeWhat like this:
RequestBuilder rb = new RequestBuilder("RequestBuilder.POST","URL");
rb.sendRequestData ("Some String");

So the servlet is some class which extends HttpServlet.

I am able to see that the Request is invoking the Servlet , but some
how it is neither opening an inline window or any attachment.
And there are no exceptions caught at the console. Can you please
suggest me how to go about it

Many thanks for the time

Uemit

unread,
Sep 2, 2011, 11:14:31 AM9/2/11
to google-we...@googlegroups.com, prave...@gmail.com
So you want to send some data to the servlet and want to display a PDF (which is generated by the servlet based on the data sent) in the browser?

There are two ways of how to do it: 

1.) Using RequestBuilder you could generate a AJAX call to your Servlet (as you did it). However in the callback method of the RequestBuilder you will get the response from the servlet (probably the PDF binary data) and then you could use that to open a new window with the binary PDF data.

however I think the easier approach is the following:

2.) Have either a form or a URL which points to the URL of the servlet responsible for generating the PDF. The data you want to pass to the servlet can bei either passed by POST (form) or GET (url) and in the servlet make sure that response headers are set properly (application/PDF). 

second appraoch is easier. 


suresh babu

unread,
Sep 3, 2011, 3:37:30 AM9/3/11
to google-we...@googlegroups.com
use Window.open("/pdfUrl",  "_blank", "");  in gwt to call the servlet, in servlet write the code for generating pdf.




--
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/-/YleAom9t2JQJ.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Regards
Suresh Babu G



Abduxkur Ablimit

unread,
Sep 4, 2011, 9:32:02 PM9/4/11
to google-we...@googlegroups.com
try this

        export.addClickHandler(new ClickHandler(){
            public void onClick(ClickEvent event) {
                String link = GWT.getModuleBaseURL() + "exportServlet?year="+year.getValue(year.getSelectedIndex())+"&month="+month.getValue(month.getSelectedIndex());
                Window.Location.replace(link);
            }
        });


because using Ajax request to download file is not possible.

From: Praveen Ramachandran <prave...@gmail.com>
To: Google Web Toolkit <google-we...@googlegroups.com>
Cc: prave...@gmail.com
Sent: Friday, September 2, 2011 8:40 PM
Subject: Gwt RequestBuilder + Servlet issue
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages