• 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

Download a File from server to client machine - web application

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all…

I need to implement the following functionality:

I have a web application running under Apache Tomcat.
The user will have to provide a full path, choosing where to locate the file he wishes to download from the server. It is basically the opposite operation of upload.

I have encountered this issue while "Googling", trying to find an appropriate solution. The only solution which doesn’t fit was using a servlet and writing the file into the HttpServletResponse object!
I can’t use this kind of solution, since the user is been promoted with the File Download Dialog, which I am trying to avoid.

I have explored the HttpServletRequest object ,It seems I can extract the following data:
iHttpServletRequest.getRemoteAddr();
iHttpServletRequest.getRemoteHost();
iHttpServletRequest.getRemotePort();

Is there any change I can use the IP Address to achieve the above?

I hope I was clear enough, Thanks for any help (solutions or Ideas!!!)

Natalie
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

I don't think this is possible, and I certainly hope I'm right. I definitely do not want to access a website that starts writing data on my hard disk (other than cookies / cache data) without asking me first. No, you're really going to have to ask your users to save the file where they want to.

You may be able to use the remote IP address if and only if the machines are accessible by a preset means like Windows file sharing. Unless you're working within your own corporate or private network, where you can enforce this, you can forget about your requirements.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Natalie Afota wrote:the user is been promoted with the File Download Dialog, which I am trying to avoid.


Not possible. Thank goodness.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sure that you can download the files from server using the response object and by setting the response type as "application/pdf" in the resultant jsp header.
But you can never write files to your disk automatically as it is a web application.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ajeeth Kumar wrote:I am sure that you can download the files from server using the response object and by setting the response type as "application/pdf" in the resultant jsp header.
I am also implementing the same behaviour in a web app and it works fine in windows


Except that that will not meet the (impossible) requirements of the original poster to write the file automatically to the file system of the client machine without user intervention.
 
Natalie Afota
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey

I will give you guys some background…

I am implementing web applications for our company internal use (in internal network!)

In this scenario, the user is expecting the file to be copied to his local drive.

I understand that in the real web achieving this kind of functionality can be a real security hazard!

The clients are running under windows but the server is running under Linux!

Having the client IP address is not enough? Using some copy file protocol something like FTP?

Still hope to find solution!

Thanks all, Natalie
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The technical name for software that silently writes files to peoples computers is "virus". So you won't get any help from standard web protocols.

Furthermore, knowing the client's IP address does you no good, since HTTP is a strict request/response protocol. It cannot send anything down to the client that's unsolicited or to anywhere but the receiving socket on the client-to-server connection. Which will be closed immediately after the response has been received.

You will need client-side code to do what you're looking for. It can be an ActiveVirus, er ActiveX control or a signed applet or something like that, but basically it's got to be something that operates outside the normal sandbox security for J2EE.

A possible alternative for Windows users might be to supply the file through Windows provisioning services, which I believe are still called "SMS", if the Marketing Department hasn't decided to "improve" the name.

Another possible alternative would be to simply keep the file on a network share that the webserver has write access writes to so that the webserver can do out-of-band writes to the file. There are good arguments for this, as long as you don't truly need the file on the user's local machine (for example for disconnected laptop use).
 
Natalie Afota
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey

Tim Holloway wrote:A possible alternative for Windows users might be to supply the file through Windows provisioning services, which I believe are still called "SMS", if the Marketing Department hasn't decided to "improve" the name.



Where can I find more information regarding Windows provisioning services?

Thanks, Natalie
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd try google.
 
reply
    Bookmark Topic Watch Topic
  • New Topic