• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can a servlet architecture download a file?

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Glenn Murray
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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



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



J.
 
Glenn Murray
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Glenn Murray
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic