This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
The application is running on Server "A", I am working on client machine "B". How to write a file to the directory of local machine (for example, c:\myDoc)? If using File and FileWriter (or FileOutputStream), it can not work cross network. So file is write to the Server "A" instead of Client machine "B". If using ServletResponse.getOutputStream(), no file directory can be specified. How can I do that? Thanks a lot.
Short answer: you can't. This is not strictly a SErvlet or JSP thing, its a HTTP security thing. Otherwise visiting a web page could result in people writing viruses, overwriting properties, or even have Microsoft detect a Linux operating system and overwrite it with Windows One thing you can do is have someone make a request to a Servlet, then have the Servlet return a file to the client. The default for web pages is to return content with the mime-type of text/html and for the browser to handle this (by showing it on the screen) There are other mime-types that browsers can handle (like images and movies), but if the browser doesn't know what to do with the file, it will prompt the user to save it on the harddrive (and they get to decide where to save it). This isn't a complete solution (and may not work cos I ripped from the middle of an existing class) but it should give an idea... The only tricky bit is the Disposition Header, which changes the name of the file to the real filename.
One thing u can do is to have a digital signature. This means asking the client to give permissions to access his machine. If the client accepts, then the server can be able to do IO operations on the client machine.
Otherwise visiting a web page could result in people writing viruses, overwriting properties, or even have Microsoft detect a Linux operating system and overwrite it with Windows
... and charge the webmaster for licence and consulting fees
tobe bondhu nouka bherao<br />shonabo gaan aj shara raat
Joined: Apr 11, 2002
Thanks to all your guys!
Joined: Feb 05, 2002
There are lots of commercial digital sinatures available in the market. U have to include this in ur applet/html (client). When the page loads, it will prompt the user to grant permissions for IO. U can get more technical info on this in the web. I have used this long back and I really dont remember it now.