Weird EOF Exception while trying to download file from GWT application

2010-12-23 Thread tarun
Hi,
I am trying to download a file from GWT client. At server side there
is a servlet which generates content of file as per request and send
it back to the client.

Test Scenarios:

Scenario 1 If I hit url of servlet directly, it always give me desired
result without any problems.

Scenario 2 Using GWT client on IE8,I am able to download file without
any code changes. However on some other computer as soon as I try to
write file content on response output stream, I get EOF exception.

org.mortbay.jetty.EofException
at org.mortbay.jetty.HttpGenerator.flush(HttpGenerator.java:760)
at org.mortbay.jetty.AbstractGenerator
$Output.flush(AbstractGenerator.java:566)
at org.mortbay.jetty.HttpConnection$Output.flush(HttpConnection.java:
911)
at java.io.BufferedOutputStream.flush(Unknown Source)
at.doGet(ServiceDataExporterServlet.java:
110)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:
717)Creating input stream


Code of servlet is as follows:


try
{
output = new BufferedOutputStream(response.getOutputStream(),
DEFAULT_BUFFER_SIZE);
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int length;
int bytesWritten=0;
while ((length = data.read(buffer))  0) {
bytesWritten+=length;
output.write(buffer, 0, length);
}
output.flush() // At this point I am facing EOF exception.

where data is inputStream

Via means of bytesWritten variable I have confirmed that in all the
three scenarios content has been written in the same way in output
stream. But not sure why it is not working in some computers.

Any pointers will be highly appereciated.

-- 
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-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Weird EOF Exception while trying to download file from GWT application

2010-12-23 Thread Patrick Tucker
I know this sounds crazy but in the past I've run into this and this
seemed to fixed the problem...

...
OutputStream os;

try
{
os = response.getOutputStream(),

BufferedOutputStream output = new BufferedOutputStream(os,
DEFAULT_BUFFER_SIZE);
...
}

if (os != null)  os.flush();

Also, have you tried wrapping the flush() in a try catch and ignore
the thrown exception?

On Dec 23, 5:13 am, tarun aloneparrot...@gmail.com wrote:
 Hi,
 I am trying to download a file from GWT client. At server side there
 is a servlet which generates content of file as per request and send
 it back to the client.

 Test Scenarios:

 Scenario 1 If I hit url of servlet directly, it always give me desired
 result without any problems.

 Scenario 2 Using GWT client on IE8,I am able to download file without
 any code changes. However on some other computer as soon as I try to
 write file content on response output stream, I get EOF exception.

 org.mortbay.jetty.EofException
 at org.mortbay.jetty.HttpGenerator.flush(HttpGenerator.java:760)
 at org.mortbay.jetty.AbstractGenerator
 $Output.flush(AbstractGenerator.java:566)
 at org.mortbay.jetty.HttpConnection$Output.flush(HttpConnection.java:
 911)
 at java.io.BufferedOutputStream.flush(Unknown Source)
 at.doGet(ServiceDataExporterServlet.jav­a:
 110)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:
 717)Creating input stream

 Code of servlet is as follows:

 try
 {
 output = new BufferedOutputStream(response.getOutputStream(),
 DEFAULT_BUFFER_SIZE);
 byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
 int length;
 int bytesWritten=0;
 while ((length = data.read(buffer))  0) {
 bytesWritten+=length;
 output.write(buffer, 0, length);}

 output.flush() // At this point I am facing EOF exception.

 where data is inputStream

 Via means of bytesWritten variable I have confirmed that in all the
 three scenarios content has been written in the same way in output
 stream. But not sure why it is not working in some computers.

 Any pointers will be highly appereciated.

-- 
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-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Download file with GWT

2008-09-11 Thread Simon Rydberg

I'm having the same problem.. I have a servlet that I make a POST ( I
can't do a GET request because I send a lot of data to the servlet )
request with the RequestBuilder to the servlet and it recives all the
data, creates, in my case an excel file and then the client recives
the responce in a RequestCallback. And then nothing happens, except
that the status of the responce is OK with code 200.. I want the user
to see the download file form when the responce comes.

I have searched this group and via google with an answer to my
problem. Found some answers when you are making a GET-request, but
nothing when you make a POST request...
--~--~-~--~~~---~--~~
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-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Download file with GWT

2008-09-11 Thread Folke

Plan A: Storing the file on the server.

1. Submit the data to the server
2. The server converts and stores the Excel data (temporarily) and
assigns an ID
3. ID is sent back to the client
4. Open a new window or use an iframe with the download URL containing
the ID as GET parameter
5. Server sends the Excel data with MIME type application/octet-
stream.
6. Save as ... dialog opens.
7. ???
8. Profit!

Plan B: IFrame with form submit
1. Create an invisible IFrame containing a form with your data in a
hidden field
2. Submit the form via Javascript.
3. (magick)
4. Save as ... dialog opens.
5. ???
6. Profit!


On Sep 11, 10:34 am, Simon Rydberg [EMAIL PROTECTED] wrote:
 I'm having the same problem.. I have a servlet that I make a POST ( I
 can't do a GET request because I send a lot of data to the servlet )
 request with the RequestBuilder to the servlet and it recives all the
 data, creates, in my case an excel file and then the client recives
 the responce in a RequestCallback. And then nothing happens, except
 that the status of the responce is OK with code 200.. I want the user
 to see the download file form when the responce comes.

 I have searched this group and via google with an answer to my
 problem. Found some answers when you are making a GET-request, but
 nothing when you make a POST request...
--~--~-~--~~~---~--~~
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-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Download file with GWT

2008-09-11 Thread Reinier Zwitserloot

1. The server has to send the file with a data type of application/
octet-stream.
2. You can't use an AJAX call (RequestBuilder / HttpRequest / GWT-
RPC), those will never generate a save as box on the user's client.
Use:

1. A link that a user clicks on.
2. open a new window using Window.open
3. redirect the current page to your excel page. I'm not sure if
there's a GWT way, but with JSNI it's a matter of window.location =
http://whatever;';
4. Like #3, but do this in an iframe you just created, so that the
user doesn't lose the GWT page.

On Sep 11, 11:08 am, Folke [EMAIL PROTECTED] wrote:
 Plan A: Storing the file on the server.

 1. Submit the data to the server
 2. The server converts and stores the Excel data (temporarily) and
 assigns an ID
 3. ID is sent back to the client
 4. Open a new window or use an iframe with the download URL containing
 the ID as GET parameter
 5. Server sends the Excel data with MIME type application/octet-
 stream.
 6. Save as ... dialog opens.
 7. ???
 8. Profit!

 Plan B: IFrame with form submit
 1. Create an invisible IFrame containing a form with your data in a
 hidden field
 2. Submit the form via Javascript.
 3. (magick)
 4. Save as ... dialog opens.
 5. ???
 6. Profit!

 On Sep 11, 10:34 am, Simon Rydberg [EMAIL PROTECTED] wrote:

  I'm having the same problem.. I have a servlet that I make a POST ( I
  can't do a GET request because I send a lot of data to the servlet )
  request with the RequestBuilder to the servlet and it recives all the
  data, creates, in my case an excel file and then the client recives
  the responce in a RequestCallback. And then nothing happens, except
  that the status of the responce is OK with code 200.. I want the user
  to see the download file form when the responce comes.

  I have searched this group and via google with an answer to my
  problem. Found some answers when you are making a GET-request, but
  nothing when you make a POST request...
--~--~-~--~~~---~--~~
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-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Download file with GWT

2008-09-11 Thread Jason Essington

Number 1 is actually very important. If you are going to use  
Window.open it has to be done as a direct result of a user action,  
otherwise popup blockers will prevent the window from being opened.  
This means that you can't place the Window.open command in a callback  
or any kind of deferred call.

-jason


On Sep 11, 2008, at 5:45 AM, Reinier Zwitserloot wrote:

 1. A link that a user clicks on.
 2. open a new window using Window.open


--~--~-~--~~~---~--~~
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-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---