KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > filters > upload > FileUploadWrapper


1 /*
2 * @author : Reghu
3 * @Version : 1.0
4 *
5 * Development Environment : Oracle9i JDeveloper
6 * Name of the File : FileUpload.java
7 * Creation/Modification History :
8 *
9 * Reghu 21-Jan-2002 Created
10 *
11 */

12
13 package filters.upload;
14
15 // Java IO classes
16
import java.io.IOException JavaDoc;
17
18 // Servlet related classes
19
import javax.servlet.http.HttpServletRequestWrapper JavaDoc;
20 import javax.servlet.http.HttpServletRequest JavaDoc;
21
22 /**
23  * A wrapper class for the HttpServletRequest to handle multipart/form-data
24  * requests, the kind of requests that support file uploads.
25  */

26 public class FileUploadWrapper extends HttpServletRequestWrapper JavaDoc {
27
28   // The file upload utility class instance
29
FileUpload mreq = null;
30   
31   /**
32    * Returns the value of a request parameter as a String, or null if
33    * the parameter does not exist.The method overrides parent method.
34    * @param <b>name</b> The name of the parameter
35    * @return <b>String </b> The value of the paramter
36    */

37   public String JavaDoc getParameter( String JavaDoc name ) {
38     return mreq.getParameter( name );
39   }
40   
41   /**
42    * Returns an Enumeration of String objects containing the names of the
43    * parameters contained in this request. If the request has no parameters,
44    * the method returns an empty Enumeration.The method overrides parent method.
45    * @return <b>Enumeration </b>of String objects, each String containing the
46    * name of a request parameter; or an empty Enumeration if the request has
47    * no parameters
48    */

49   public java.util.Enumeration JavaDoc getParameterNames() {
50     return mreq.getParameterNames();
51   }
52   /**
53    * Returns an array of String objects containing all of the values the given
54    * request parameter has, or null if the parameter does not exist.
55    * The method overrides parent method.
56    * @param <b>name</b> the name of the parameter whose value is requested
57    * @return <b><String[]</b> an array of String objects containing the
58    * parameter's values
59    */

60   public String JavaDoc[] getParameterValues( String JavaDoc name ) {
61     return mreq.getParameterValues( name );
62   }
63   
64   /**
65    * The constructor for the HttpServletRequestWrapper
66    * @param <b>request </b>The original request
67    * @param <b>dir</b> file upload directory path
68    * @throws <b>IOException</b> If there was a failure while instantiating
69    * the FileUpload object
70    */

71   public FileUploadWrapper( HttpServletRequest JavaDoc req, String JavaDoc dir )
72               throws IOException JavaDoc {
73     super( req );
74     mreq = new FileUpload( req, dir );
75   }
76 }
77
Popular Tags