FileDocCategorySizeDatePackage
UploadBean.javaAPI DocExample1666Fri Jun 20 05:32:18 BST 2003com.jspservletcookbook

UploadBean

public class UploadBean extends Object

Fields Summary
private String
webTempPath
private HttpServletRequest
req
private String
dir
Constructors Summary
public UploadBean()

Methods Summary
public java.lang.StringgetUploadedFiles()

   
      //file limit size of five megabytes
      MultipartRequest mpr = new MultipartRequest(
        req,webTempPath,5 * 1024 * 1024,new MyFileRenamePolicy());

      Enumeration enum = mpr.getFileNames();

      StringBuffer buff = new StringBuffer("");
        
      for (int i = 1; enum.hasMoreElements();i++){

            buff.append("The name of uploaded file ").append(i).
              append(" is: ").
                append(mpr.getFilesystemName((String)enum.nextElement())).
                  append("<br><br>");
      }//for
        
      //return the String
      return buff.toString();

  
public voidsetDir(java.lang.String dirName)


      if (dirName == null || dirName.equals(""))
        throw new IllegalArgumentException(
           "invalid value passed to " + getClass().getName()+".setDir");

      webTempPath = dirName;

  
public voidsetReq(javax.servlet.ServletRequest request)


      if (request != null && request instanceof HttpServletRequest){

          req = (HttpServletRequest) request;

      } else {
  
          throw new IllegalArgumentException(
            "Invalid value passed to " + getClass().getName()+".setReq");
      }