Automatically updated JSP download page
The method is to pass one JavaBean. JavaBean is excited in the JSBEAN, and when the folder is updated, JavaBean searches for updated files and the existing files. Visitors download. Each of the downloaded files (such as file.zip) has a corresponding description file (such as file.txt), this JavaBean will display the description of the file .txt as a description of the download file as an additional information as a download link. If there is no corresponding .txt description file, "no descrition" will be displayed.
Below is the content of JavaBean
/ * * Created on 2004-7-22 * @Author lingch * * functions: * 1. Search the Directory for Files. * 2. Return The Coresponding .txt description content. * / Package p; import java.io. *; Import java.util. *;
public class files_lookup {File files; Vector result; public files_lookup () {} public Vector lookup_files (String path) // --------- path should be the downloads dir {Vector result = new Vector (); files = new file (path); string sub_files []; if (files.Indirectory ()) {sub_files = files.list (); // --------- List all files under downloads dir} else {Result .add ("path" path "is not a dir"); returnrate;} for (int i = 0; i
The JSP page can organize <% @ Page ContentType = "text / html; charset = GB2312" Language = "" "@ Page Language =" Java "import =" p. * "%>
FILE: <% out.print (v.get (i));%> p> < P> DECRIPTION: <% out.print (lb.get_file_description (Path "//" v.get (I)):" i / />>