Java Doc for MultipartRequest.java in  » Web-Framework » Millstone » org » millstone » webadapter » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » Millstone » org.millstone.webadapter 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.millstone.webadapter.MultipartRequest

All known Subclasses:   org.millstone.webadapter.ServletMultipartRequest,
MultipartRequest
public class MultipartRequest (Code)
A Multipart form data parser. Parses an input stream and writes out any files found, making available a hashtable of other url parameters. As of version 1.17 the files can be saved to memory, and optionally written to a database, etc.

Copyright (C)2001 Jason Pell.
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Email: jasonpell@hotmail.com Url: http://www.geocities.com/jasonpell

author:
   Jason Pell
version:
   1.18 Fixed some serious bugs. A new method readAndWrite(InputStream in, OutputStream out) which now does
version:
   the generic processing in common for readAndWriteFile and readFile. The differences are that now
version:
   the two extra bytes at the end of a file upload are processed once, instead of after each line. Also
version:
   if an empty file is encountered, an outputstream is opened, but then deleted if no data written to it.
version:
   The getCharArray() method has been removed. Replaced by the new String(bytes, encoding) method using
version:
   a specific encoding (Defaults to ISO-8859-1) to ensure that extended characters are supported.
version:
   All strings are processed using this encoding. The addition of static methods setEncoding(String)
version:
   and getEncoding() to allow the use of MultipartRequest with a specific encoding type. All instances
version:
   of MultipartRequest will utilise the static charEncoding variable value, that the setEncoding() method
version:
   can be used to set. Started to introduce support for multiple file uploads with the same form field
version:
   name, but not completed for v1.18. 26/06/2001
version:
   1.17 A few _very_ minor fixes. Plus a cool new feature added. The ability to save files into memory.
version:
   Thanks to Mark Latham for the idea and some of the code. 11/04/2001
version:
   1.16 Added support for multiple parameter values. Also fixed getCharArray(...) method to support
version:
   parameters with non-english ascii values (ascii above 127). Thanks to Stefan Schmidt &
version:
   Michael Elvers for this. (No fix yet for reported problems with Tomcat 3.2 or a single extra
version:
   byte appended to uploads of certain files). By 1.17 hopefully will have a resolution for the
version:
   second problem. 14/03/2001
version:
   1.15 A new parameter added, intMaxReadBytes, to allow arbitrary length files. Released under
version:
   the LGPL (Lesser General Public License). 03/02/2001
version:
   1.14 Fix for IE problem with filename being empty. This is because IE includes a default Content-Type
version:
   even when no file is uploaded. 16/02/2001
version:
   1.13 If an upload directory is not specified, then all file contents are sent into oblivion, but the
version:
   rest of the parsing works as normal.
version:
   1.12 Fix, was allowing zero length files. Will not even create the output file until there is
version:
   something to write. getFile(String) now returns null, if a zero length file was specified. 06/11/2000
version:
   1.11 Fix, in case Content-type is not specified.
version:
   1.1 Removed dependence on Servlets. Now passes in a generic InputStream instead.
version:
   "Borrowed" readLine from Tomcat 3.1 ServletInputStream class,
version:
   so we can remove some of the dependencies on ServletInputStream.
version:
   Fixed bug where a empty INPUT TYPE="FILE" value, would cause an exception.
version:
   1.0 Initial Release.


Field Summary
final public static  intCONTENTS
     Type constant for the File CONTENTS.
final public static  intCONTENT_TYPE
     Type constant for the File CONTENT_TYPE.
final public static  intFILENAME
     Type constant for File FILENAME.
final public static  intMAX_READ_BYTES
     Prevent a denial of service by defining this, will never read more data.
final public static  intREAD_LINE_BLOCK
     Defines the number of bytes to read per readLine call.
final public static  intSIZE
     Type constant for the File SIZE.

Constructor Summary
public  MultipartRequest(String strContentTypeText, int intContentLength, InputStream in, String strSaveDirectory)
     Constructor.
Parameters:
  strContentTypeText - The "Content-Type" HTTP header value.
Parameters:
  intContentLength - The "Content-Length" HTTP header value.
Parameters:
  in - The InputStream to read and parse.
Parameters:
  strSaveDirectory - The temporary directory to save the file from where they can then be moved to wherever by thecalling process.
public  MultipartRequest(String strContentTypeText, int intContentLength, InputStream in, String strSaveDirectory, int intMaxReadBytes)
     Constructor.
Parameters:
  strContentTypeText - The "Content-Type" HTTP header value.
Parameters:
  intContentLength - The "Content-Length" HTTP header value.
Parameters:
  in - The InputStream to read and parse.
Parameters:
  strSaveDirectory - The temporary directory to save the file from where they can then be moved to wherever by thecalling process.
public  MultipartRequest(PrintWriter debug, String strContentTypeText, int intContentLength, InputStream in, String strSaveDirectory)
     Constructor.
Parameters:
  debug - A PrintWriter that can be used for debugging.
Parameters:
  strContentTypeText - The "Content-Type" HTTP header value.
Parameters:
  intContentLength - The "Content-Length" HTTP header value.
Parameters:
  in - The InputStream to read and parse.
Parameters:
  strSaveDirectory - The temporary directory to save the file from where they can then be moved to wherever by thecalling process.
public  MultipartRequest(PrintWriter debug, String strContentTypeText, int intContentLength, InputStream in, int intMaxReadBytes)
    
public  MultipartRequest(PrintWriter debug, String strContentTypeText, int intContentLength, InputStream in, String strSaveDirectory, int intMaxReadBytes)
     Constructor.
Parameters:
  debug - A PrintWriter that can be used for debugging.
Parameters:
  strContentTypeText - The "Content-Type" HTTP header value.
Parameters:
  intContentLength - The "Content-Length" HTTP header value.
Parameters:
  in - The InputStream to read and parse.
Parameters:
  strSaveDirectory - The temporary directory to save the file from where they can then be moved to wherever by thecalling process.

Method Summary
protected  voiddebug(String x)
     Use when debugging this object.
public  StringgetContentType(String strName)
     Returns the Content-Type of a file.
public  StringgetEncoding()
     Returns the current encoding method.
public  FilegetFile(String strName)
     Returns a File reference to the uploaded file.
public  InputStreamgetFileContents(String strName)
     If files were uploaded into memory, this method will retrieve the contents of the file as a InputStream.
public  ObjectgetFileParameter(String strName, int type)
     Access an attribute of a file upload parameter record.
Parameters:
  strName - is the form field name, used to upload the file.
public  EnumerationgetFileParameterNames()
     This enumeration will return all INPUT TYPE=FILE parameter NAMES as encountered during the upload.
public  longgetFileSize(String strName)
     Returns the File Size of a uploaded file.
public  StringgetFileSystemName(String strName)
     Get the file system basename of an uploaded file.
public  StringgetHtmlTable()
     For debugging.
public  EnumerationgetParameterNames()
     An enumeration of all URL Parameters for the current HTTP Request.
public  StringgetURLParameter(String strName)
     Return the value of the strName URLParameter.
public  EnumerationgetURLParameters(String strName)
     Return an enumeration of all values for the strName parameter.
public  voidsetEncoding(String enc)
     This method should be called on the MultipartRequest itself, not on any instances of MultipartRequest, because this sets up the encoding for all instances of multipartrequest.

Field Detail
CONTENTS
final public static int CONTENTS(Code)
Type constant for the File CONTENTS. Note: Only used for file upload to memory.



CONTENT_TYPE
final public static int CONTENT_TYPE(Code)
Type constant for the File CONTENT_TYPE.



FILENAME
final public static int FILENAME(Code)
Type constant for File FILENAME.



MAX_READ_BYTES
final public static int MAX_READ_BYTES(Code)
Prevent a denial of service by defining this, will never read more data. If Content-Length is specified to be more than this, will throw an exception. This limits the maximum number of bytes to the value of an int, which is 2 Gigabytes.



READ_LINE_BLOCK
final public static int READ_LINE_BLOCK(Code)
Defines the number of bytes to read per readLine call. 128K



SIZE
final public static int SIZE(Code)
Type constant for the File SIZE.




Constructor Detail
MultipartRequest
public MultipartRequest(String strContentTypeText, int intContentLength, InputStream in, String strSaveDirectory) throws IllegalArgumentException, IOException(Code)
Constructor.
Parameters:
  strContentTypeText - The "Content-Type" HTTP header value.
Parameters:
  intContentLength - The "Content-Length" HTTP header value.
Parameters:
  in - The InputStream to read and parse.
Parameters:
  strSaveDirectory - The temporary directory to save the file from where they can then be moved to wherever by thecalling process. If you specify null for this parameter, then any files uploadedwill be silently ignored.
exception:
  IllegalArgumentException - If the strContentTypeText does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
exception:
  IOException - If the intContentLength is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
See Also:   MultipartRequest.MAX_READ_BYTES



MultipartRequest
public MultipartRequest(String strContentTypeText, int intContentLength, InputStream in, String strSaveDirectory, int intMaxReadBytes) throws IllegalArgumentException, IOException(Code)
Constructor.
Parameters:
  strContentTypeText - The "Content-Type" HTTP header value.
Parameters:
  intContentLength - The "Content-Length" HTTP header value.
Parameters:
  in - The InputStream to read and parse.
Parameters:
  strSaveDirectory - The temporary directory to save the file from where they can then be moved to wherever by thecalling process. If you specify null for this parameter, then any files uploadedwill be silently ignored.
Parameters:
  intMaxReadBytes - Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
exception:
  IllegalArgumentException - If the strContentTypeText does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
exception:
  IOException - If the intContentLength is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
See Also:   MultipartRequest.MAX_READ_BYTES



MultipartRequest
public MultipartRequest(PrintWriter debug, String strContentTypeText, int intContentLength, InputStream in, String strSaveDirectory) throws IllegalArgumentException, IOException(Code)
Constructor.
Parameters:
  debug - A PrintWriter that can be used for debugging.
Parameters:
  strContentTypeText - The "Content-Type" HTTP header value.
Parameters:
  intContentLength - The "Content-Length" HTTP header value.
Parameters:
  in - The InputStream to read and parse.
Parameters:
  strSaveDirectory - The temporary directory to save the file from where they can then be moved to wherever by thecalling process. If you specify null for this parameter, then any files uploadedwill be silently ignored.
exception:
  IllegalArgumentException - If the strContentTypeText does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
exception:
  IOException - If the intContentLength is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
See Also:   MultipartRequest.MAX_READ_BYTES



MultipartRequest
public MultipartRequest(PrintWriter debug, String strContentTypeText, int intContentLength, InputStream in, int intMaxReadBytes) throws IllegalArgumentException, IOException(Code)
Constructor - load into memory constructor
Parameters:
  debug - A PrintWriter that can be used for debugging.
Parameters:
  strContentTypeText - The "Content-Type" HTTP header value.
Parameters:
  intContentLength - The "Content-Length" HTTP header value.
Parameters:
  in - The InputStream to read and parse.
Parameters:
  intMaxReadBytes - Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
exception:
  IllegalArgumentException - If the strContentTypeText does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
exception:
  IOException - If the intContentLength is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
See Also:   MultipartRequest.MAX_READ_BYTES



MultipartRequest
public MultipartRequest(PrintWriter debug, String strContentTypeText, int intContentLength, InputStream in, String strSaveDirectory, int intMaxReadBytes) throws IllegalArgumentException, IOException(Code)
Constructor.
Parameters:
  debug - A PrintWriter that can be used for debugging.
Parameters:
  strContentTypeText - The "Content-Type" HTTP header value.
Parameters:
  intContentLength - The "Content-Length" HTTP header value.
Parameters:
  in - The InputStream to read and parse.
Parameters:
  strSaveDirectory - The temporary directory to save the file from where they can then be moved to wherever by thecalling process. If you specify null for this parameter, then any files uploadedwill be silently ignored.
Parameters:
  intMaxReadBytes - Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
exception:
  IllegalArgumentException - If the strContentTypeText does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
exception:
  IOException - If the intContentLength is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
See Also:   MultipartRequest.MAX_READ_BYTES




Method Detail
debug
protected void debug(String x)(Code)
Use when debugging this object.



getContentType
public String getContentType(String strName)(Code)
Returns the Content-Type of a file.
See Also:   MultipartRequest.getFileParameter(java.lang.String,int)



getEncoding
public String getEncoding()(Code)
Returns the current encoding method.



getFile
public File getFile(String strName)(Code)
Returns a File reference to the uploaded file. This reference is to the files uploaded location, and allows you to read/move/delete the file. This method is only of use, if files were uploaded to the file system. Will return null if uploaded to memory, in which case you should use getFileContents(strName) instead. Returns a null file reference if a call to getFileSize(strName) returns zero or files wereuploaded to memory.
See Also:   MultipartRequest.getFileSize(java.lang.String)
See Also:   MultipartRequest.getFileContents(java.lang.String)
See Also:   MultipartRequest.getFileSystemName(java.lang.String)



getFileContents
public InputStream getFileContents(String strName)(Code)
If files were uploaded into memory, this method will retrieve the contents of the file as a InputStream. the contents of the file as a InputStream, or null if not file uploaded,or file uploaded to file system directory.
See Also:   MultipartRequest.getFileParameter(java.lang.String,int)



getFileParameter
public Object getFileParameter(String strName, int type)(Code)
Access an attribute of a file upload parameter record.
Parameters:
  strName - is the form field name, used to upload the file. This identifiesthe formfield location in the storage facility.
Parameters:
  strFilename - This is the FileSystemName of the file
Parameters:
  type - What attribute you want from the File Parameter.The following types are supported:MultipartRequest.FILENAME, MultipartRequest.CONTENT_TYPE, MultipartRequest.SIZE,MultipartRequest.CONTENTS

The getFileSystemName(String strName),getFileSize(String strName),getContentType(String strName),getContents(String strName) methods all use this method passing in a different type argument.

Note: This class has been changed to provide for future functionality where youwill be able to access all files uploaded, even if they are uploaded using the sameform field name. At this point however, only the first file uploaded via a formfield name is accessible.


See Also:   MultipartRequest.getContentType(java.lang.String)
See Also:   MultipartRequest.getFileSize(java.lang.String)
See Also:   MultipartRequest.getFileContents(java.lang.String)
See Also:   MultipartRequest.getFileSystemName(java.lang.String)



getFileParameterNames
public Enumeration getFileParameterNames()(Code)
This enumeration will return all INPUT TYPE=FILE parameter NAMES as encountered during the upload.



getFileSize
public long getFileSize(String strName)(Code)
Returns the File Size of a uploaded file. -1 if file size not defined.
See Also:   MultipartRequest.getFileParameter(java.lang.String,int)



getFileSystemName
public String getFileSystemName(String strName)(Code)
Get the file system basename of an uploaded file. null if strName not found.
See Also:   MultipartRequest.getFileParameter(java.lang.String,int)



getHtmlTable
public String getHtmlTable()(Code)
For debugging.



getParameterNames
public Enumeration getParameterNames()(Code)
An enumeration of all URL Parameters for the current HTTP Request.



getURLParameter
public String getURLParameter(String strName)(Code)
Return the value of the strName URLParameter. If more than one value for a particular Parameter, will return the first. If an error occurs will return null.



getURLParameters
public Enumeration getURLParameters(String strName)(Code)
Return an enumeration of all values for the strName parameter. Even if a single value for, will always return an enumeration, although it may actually be empty if no value was encountered for strName or it is an invalid parameter name.



setEncoding
public void setEncoding(String enc) throws UnsupportedEncodingException(Code)
This method should be called on the MultipartRequest itself, not on any instances of MultipartRequest, because this sets up the encoding for all instances of multipartrequest. You can set the encoding to null, in which case the default encoding will be applied. The default encoding if this method is not called has been set to ISO-8859-1, which seems to offer the best hope of support for international characters, such as german "Umlaut" characters.

Warning: In multithreaded environments it is the responsibility of the implementer to make sure that this method is not called while another instance is being constructed. When an instance of MultipartRequest is constructed, it parses the input data, and uses the result of getEncoding() to convert between bytes and strings. If setEncoding() is called by another thread, while the private parse() is executing, the method will utilise this new encoding, which may cause serious problems.




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.