Forums Register Login

Can a servlet architecture download a file?

+Pie Number of slices to send: Send
Hi, I'm a servlet newbie and thought they might be a solution to my
problem, but now I wonder.

I want to run a Big Ol' Number Cruncher (BONC) on a server. From my
Java client (NOT a web browser) I want to submit a job over the
network and have the BONC run it. Currently I do this locally,
which ties up the client machine.

If a servlet does this, can the servlet, at the client's request,
then send the BONC's zipped output file back to the client? (The
unzipped output may be hundreds of MB). Searches of the web and
O'Reilly's "Servlet Programming" have not indicated that this is
possible.

Are servlets too brain dead to do this sort of thing? I would prefer
not to run a web server on the BONC server. Should I be looking at a
different technology (Globus Toolkit seems like overkill)? Surely
this has been done before.

Any help would be appreciated! Many thanks,
Glenn
+Pie Number of slices to send: Send
You should be able to do this with a servlet.
Tomcat can even take care of the gzip compression for you.
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/http.html
+Pie Number of slices to send: Send
Thanks, Ben!

At first blush, this looks plausible, but I can't find any examples.
It seems the API is

http://jakarta.apache.org/tomcat/tomcat-5.0-doc/catalina/docs/api/org/apache/coyote/tomcat5/package-summary.html

With these classes it seems I could read a server file and write
it, but what is happening on the client side? I think I'll have
to learn what this HTTPResponse business is.

Also, I don't see anything about compression, yet. I'll poke around.
The HTTPConnector business is pretty mysterious.

Thanks for the link, though.

Cheers,
Glenn
+Pie Number of slices to send: Send
 

Also, I don't see anything about compression, yet. I'll poke around.
The HTTPConnector business is pretty mysterious.



A "ctl+f" on the link I gave you with "compressableMimeType" and "compression" should give you the Tomcat specific settings for gziping your responses.
+Pie Number of slices to send: Send
For the client side, you might look at the HttpClient package one of the Jakarta Commons projects. This will give you convenient methods for talking to a servlet from a non-browser client.
Bill
+Pie Number of slices to send: Send
 


I think I'll have
to learn what this HTTPResponse business is.



I think this is a brillant idea when working with Servlets.



J.
+Pie Number of slices to send: Send
Hi,

Thanks much to all who responded. I get the feeling that Tomcat actually
might do the job. I installed 5.5.9 and browsed to the default page.
Next I'll see if I can write a Java client to contact Tomcat, and then
see if I can send a servlet something and get a response.

The more fundamental question is how to upload input files for the
BONC and download output files.

As far as compression goes, in my new installation I found that in



there is Java code which seems to send a compressed Stream via an
HttpServletResponse. I don't know why this code is there.

Thanks again!

Cheers,
Glenn
+Pie Number of slices to send: Send
Hi,

I thought I'd add some code to this thread. First, there is a servlet
with doPost() and doGet() methods. Then there is a Java client which
connects to the servlet and calls one method or the other, depending
on the value of DO_POST. The doPost() method will read a Stream from
the client, and write one back. Presumably this will work for
uploading and downloading files; note the API has different streams
for binary files. Also of interest is this link for a tool which
might simplify uploading.

Jakarta Commons File Upload

Cheers,
Glenn



Here is the client code.


Note the doGet() is based on the Tomcat 5.5.9 sample.war. I repeat that
I am a newbie at this. If you go to this servlet with a browser, the
doGet() is invoked. I couldn't find the distinction in the spec.
[ June 17, 2005: Message edited by: Glenn Murray ]
Whatever you say buddy! And I believe this tiny ad too:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1348 times.
Similar Threads
How to print
DB2 jdbc driver 6.2 on linux red Hat 7.2 it doesn't Work with Iplanet web server 6.0
DB2 jdbc driver 6.2 on linux red Hat 7.2 it doesn't Work with Iplanet web server 6.0
how to knoe if the files are being generated?
How send file data to JSP/Servlet page and save to disk?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:24:42.