Theme: JSP in how to achieve download multiple files Author: babymon () reputation value: 100 Quantity Forum: Java JSP / Servlet / JavaBean questions Points: 50 Replies: 6 Published: 2004-8-25 17: 01: 50JSP How to achieve a directory that downloads multiple files to a user, which means that the directory can only be selected when the user is downloaded.
You cannot change the file name. Thanks to everybody !!!!
Reply to: Yys79 (Shart-Shoot) () Reputation: 100 2004-8-25 17:41:30 Score: 0 It seems that it is impossible, any download software is also a download. At the same time, download the client software, the B / S structure is not
TOP
Reply to: babymon () () Reputation: 100 2004-8-25 19:04:46 Score: 0 Then I can implement multiple files of the application server to the client, and the destination directory is the user selectable.
My application server is WebLogic8
TOP
Reply to: Power17 () () Reputation: 105 2004-8-26 1:12:01 Score: 10 I wrote, using jspsmartupload.
However, there are two questions:
1. I use java.io.file file = new java.io.file ("."); The resulting directory is C: / Windows / System32 /.
I have to run a lot of friends on the Internet, the result is a certain level directory under Tomcat. Later changed to the following
G: // Web // Tomcat 5.0 // WebApps // Root // Upload (a certain level directory in my Tomcat installation directory),
It is unsuccessful to the catalog adjustment
2. You cannot download files in .txt format (open in your browser).
3. All the files after downloading have become a thumbs.db file, I don't know what this is useful.
The following is my code, strongly welcome to correct.
<% @ Page ContentType = "Text / HTML; Charset = GB2312" Language = "Java" IMPORT = "com.jspsmart.upload. *"%>
<% @ Page Import = "java.io. *"%>
hEAD>
<%
Java.io.file file = new java.io.file ("g: // Web // Tomcat 5.0 // WebApps // Root // UPLOAD");
// Get all files in the specified directory
Java.io.file [] files = file.listfiles ();
// Number of details
INT count = files.length;
// Download with JSPSMARTUPLAOD components
Smartupload su = new smartupload (); Su.initialize (PageContext);
Su.setContentDisPosition (NULL);
For (int i = 0; i String flnm = files [i] .GetabsolutePath (); Su.Downloadfile (FLNM); } %> body> html> TOP Reply to: GJD111686 (Digital King) () Reputation: 100 2004-8-26 8:09:46 Score: 40 call this JS function Function Downurl (StrRemoteurl, Strlocalurl) { Try { VAR XMLHTTP = New ActiveXObject ("Microsoft.xmlhttp"); XMLHTTP.Open ("Get", StrremoteURL, FALSE); Xmlhttp.send (); VAR AdodbStream = New ActiveXObject ("AdoDb.Stream"); AdoDBStream.Type = 1; // 1 = adtypebinary AdoDBStream.open (); AdoDBStream.write (XMLHTTP.RESPONSEBODY); AdodbStream.savetofile (StrlocalURL, 2); Adodbstream.close (); Adodbstream = NULL; XMLHTTP = NULL; } Catch (e) { WINDOW.CONFIRM ("Download URL Error!"); } //Window.confirm ("Download is complete."); } TOP Reply to: babymon () () Reputation: 100 2004-8-26 9:47:05 Score: 0 Good, try! ! TOP Reply to: GJD111686 (Digital King) () Reputation: 100 2004-8-26 9:51:30 Score: 0 Use Applets You can: Public void readURL (String Strurl) { Try { Int IhtpResult; URL M_URL = New URL (StrURL); UrlConnection M_URLCONN = M_URL.OpenConnection (); m_urlconn.connect (); HTTPURLCONNECTION M_HTTPCONN = (httpurlconnection) m_urlconn; IHTTPRESULT = m_httpconn.getResponsecode (); IHTPRESULT! = httpurlconnection.http_ok) JOPTIONPANE.SHOWMESSAGEDIALOG (this, "Unable to connect ..."); Else { INT ifilesize = m_urlconn.getContentLength (); InputStreamReader M_Reader = New InputStreamReader (M_URLCONN.GETITINPUTSTREAM ()); Char [] buffer = new char [2048]; INT INUM = 0; While (inum> -1) { InUM = m_reader.read (buffer); IF (Inum <0) Break; //JOPTIONPANE.SHOWMESSAGEDIALOG (THIS ,NEW STRING (Buffer, 0, Inum);} M_Reader.close (); } } Catch (Exception E) { JOPTIONPANE.SHOWMESSAGEDIALOG (this, E.GETMESSAGE ()); } }