This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hi, I have a x.java file in the server. When the client sends the file name and storing folder to the servlet. How to write the servlet to send the .java file directly to the folder? using FileOutputStream? Thanks
For applets in general this is not possible without a signed applet. Applications, of course, have no such restriction. But you can't "push" from a server to a client, anyway. You need to have the client cooperate in some way. For example, a application client could open a socket to the server, read the response, and write it to a local file. The server cannot do this directly any more than a client can directly write to the server's local file system. ------------------ Phil Hanna Author of : JSP: The Complete Reference Instant JavaServlets
Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
Hi, In the above piece of code, the servlet 1) gets the file name parameter 2) reads the contents of the file 3) writes the contents to the browser outstream. the applet, 1) calls the servlet passing the filename as the parameter. 2) just shows the contents (written by the servlet) in the browser window. The applet does not save the file on the client machine, but merely passes on the content to the browser for display. However, you can always save that content using the browser "Save As .. " function. Hope this helps. Ashwin.
Joined: Aug 16, 2000
hi, Ashwin, I tested the code above. It does save the file into the disk. It does not show the content into textarea, because I did not append it to any textarea. When I run it, it gives me a "save as" window and then save into my selected folder. Any expl.? Thanks