Java Doc for MultipartRequest.java in  » Groupware » hipergate » com » oreilly » servlet » 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 » Groupware » hipergate » com.oreilly.servlet 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.oreilly.servlet.MultipartRequest

MultipartRequest
public class MultipartRequest implements HttpServletRequest(Code)
A utility class to handle multipart/form-data requests, the kind of requests that support file uploads. This class emulates the interface of HttpServletRequest, making it familiar to use. It uses a "push" model where any incoming files are read and saved directly to disk in the constructor. If you wish to have more flexibility, e.g. write the files to a database, use the "pull" model MultipartParser instead.

This class can receive arbitrarily large files (up to an artificial limit you can set), and fairly efficiently too. It cannot handle nested data (multipart content within multipart content). It can now with the latest release handle internationalized content (such as non Latin-1 filenames).

To avoid collisions and have fine control over file placement, there's a constructor variety that takes a pluggable FileRenamePolicy implementation. A particular policy can choose to rename or change the location of the file before it's written.

See the included upload.war for an example of how to use this class.

The full file upload specification is contained in experimental RFC 1867, available at http://www.ietf.org/rfc/rfc1867.txt.
See Also:   MultipartParser
author:
   Jason Hunter
author:
   Geoff Soutter
version:
   1.11, 2002/11/01, combine query string params in param list

version:
   1.10, 2002/05/27, added access to the original file names

version:
   1.9, 2002/04/30, added support for file renaming, thanks to
version:
   Changshin Lee

version:
   1.8, 2002/04/30, added support for internationalization, thanks to
version:
   Changshin Lee

version:
   1.7, 2001/02/07, made fields protected to increase user flexibility

version:
   1.6, 2000/07/21, redid internals to use MultipartParser,
version:
   thanks to Geoff Soutter

version:
   1.5, 2000/02/04, added auto MacBinary decoding for IE on Mac

version:
   1.4, 2000/01/05, added getParameterValues(),
version:
   WebSphere 2.x getContentType() workaround,
version:
   stopped writing empty "unknown" file

version:
   1.3, 1999/12/28, IE4 on Win98 lastIndexOf("boundary=")
version:
   workaround

version:
   1.2, 1999/12/20, IE4 on Mac readNextPart() workaround

version:
   1.1, 1999/01/15, JSDK readLine() bug workaround

version:
   1.0, 1998/09/18



Field Summary
protected  booleanbRequestedSessionIdFromCookie
    
protected  booleanbRequestedSessionIdFromURL
    
protected  booleanbRequestedSessionIdValid
    
protected  intcontentlength
    
protected  Stringcontenttype
    
protected  Cookie[]cookies
    
protected  Stringctxpath
    
protected  Stringencoding
    
protected  Hashtablefiles
    
protected  Stringformmethod
    
protected  Hashtableparameters
    
protected  Stringpathinfo
    
protected  Stringquerystr
    
protected  Stringremoteuser
    
protected  Localerequestlocale
    
protected  Stringrequesturi
    
protected  StringBufferrequesturl
    
protected  Stringsavedir
    
protected  Stringservletpath
    
protected  Stringsessionid
    
protected  Stringtrnpath
    

Constructor Summary
public  MultipartRequest(HttpServletRequest request, String saveDirectory)
     Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to 1 Megabyte.
public  MultipartRequest(HttpServletRequest request, String saveDirectory, int maxPostSize)
     Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to the specified length.
public  MultipartRequest(HttpServletRequest request, String saveDirectory, String encoding)
     Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to the specified length.
public  MultipartRequest(HttpServletRequest request, String saveDirectory, int maxPostSize, FileRenamePolicy policy)
     Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to the specified length.
public  MultipartRequest(HttpServletRequest request, String saveDirectory, int maxPostSize, String encoding)
     Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to the specified length.
public  MultipartRequest(HttpServletRequest request, String saveDirectory, int maxPostSize, String encoding, FileRenamePolicy policy)
     Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to the specified length.
public  MultipartRequest(ServletRequest request, String saveDirectory)
     Constructor with an old signature, kept for backward compatibility. Without this constructor, a servlet compiled against a previous version of this class (pre 1.4) would have to be recompiled to link with this version.
public  MultipartRequest(ServletRequest request, String saveDirectory, int maxPostSize)
     Constructor with an old signature, kept for backward compatibility. Without this constructor, a servlet compiled against a previous version of this class (pre 1.4) would have to be recompiled to link with this version.

Method Summary
public  ObjectgetAttribute(String sAttrName)
    
public  EnumerationgetAttributeNames()
    
public  StringgetAuthType()
    
public  StringgetCharacterEncoding()
    
public  intgetContentLength()
    
public  StringgetContentType(String name)
     Returns the content type of the specified file (as supplied by the client browser), or null if the file was not included in the upload.
Parameters:
  name - the file name.
public  StringgetContentType()
    
public  StringgetContextPath()
    
public  Cookie[]getCookies()
    
public  longgetDateHeader(String hname)
    
public  FilegetFile(String name)
     Returns a File object for the specified file saved on the server's filesystem, or null if the file was not included in the upload.
Parameters:
  name - the file name.
public  FilegetFile(int number)
    
public  intgetFileCount()
    
public  EnumerationgetFileNames()
     Returns the names of all the uploaded files as an Enumeration of Strings.
public  StringgetFilesystemName(String name)
     Returns the filesystem name of the specified file, or null if the file was not included in the upload.
public  StringgetHeader(String hname)
    
public  EnumerationgetHeaderNames()
    
public  EnumerationgetHeaders(String hname)
    
public  ServletInputStreamgetInputStream()
    
public  intgetIntHeader(String hname)
    
public  StringgetLocalAddr()
    
public  StringgetLocalName()
    
public  intgetLocalPort()
    
public  LocalegetLocale()
    
public  EnumerationgetLocales()
    
public  StringgetMethod()
    
public  StringgetOriginalFileName(String name)
     Returns the original filesystem name of the specified file (before any renaming policy was applied), or null if the file was not included in the upload.
public  StringgetParameter(String name)
     Returns the value of the named parameter as a String, or null if the parameter was not sent or was sent without a value.
public  MapgetParameterMap()
    
public  EnumerationgetParameterNames()
     Returns the names of all the parameters as an Enumeration of Strings.
public  String[]getParameterValues(String name)
     Returns the values of the named parameter as a String array, or null if the parameter was not sent.
public  StringgetPathInfo()
    
public  StringgetPathTranslated()
    
public  StringgetProtocol()
    
public  StringgetQueryString()
    
public  BufferedReadergetReader()
    
public  StringgetRealPath(String s)
    
public  StringgetRemoteAddr()
    
public  StringgetRemoteHost()
    
public  intgetRemotePort()
    
public  StringgetRemoteUser()
    
public  RequestDispatchergetRequestDispatcher(String s)
    
public  StringgetRequestURI()
    
public  StringBuffergetRequestURL()
    
public  StringgetRequestedSessionId()
    
public  StringgetScheme()
    
public  StringgetServerName()
    
public  intgetServerPort()
    
public  StringgetServletPath()
    

Returns the part of this request's URL that calls the servlet.

Returns the part of this request's URL that calls the servlet.
public  HttpSessiongetSession()
    
public  HttpSessiongetSession(boolean b)
    
public  PrincipalgetUserPrincipal()
    
public  booleanisRequestedSessionIdFromCookie()
    
public  booleanisRequestedSessionIdFromURL()
    
public  booleanisRequestedSessionIdFromUrl()
    
public  booleanisRequestedSessionIdValid()
    
public  booleanisSecure()
    
public  booleanisUserInRole(String role)
    
public  voidremoveAttribute(String sAttrName)
    
public  voidsetAttribute(String sAttrName, Object sAttrVal)
    
public  voidsetCharacterEncoding(String sEncoding)
    

Field Detail
bRequestedSessionIdFromCookie
protected boolean bRequestedSessionIdFromCookie(Code)



bRequestedSessionIdFromURL
protected boolean bRequestedSessionIdFromURL(Code)



bRequestedSessionIdValid
protected boolean bRequestedSessionIdValid(Code)



contentlength
protected int contentlength(Code)



contenttype
protected String contenttype(Code)



cookies
protected Cookie[] cookies(Code)



ctxpath
protected String ctxpath(Code)



encoding
protected String encoding(Code)



files
protected Hashtable files(Code)



formmethod
protected String formmethod(Code)



parameters
protected Hashtable parameters(Code)



pathinfo
protected String pathinfo(Code)



querystr
protected String querystr(Code)



remoteuser
protected String remoteuser(Code)



requestlocale
protected Locale requestlocale(Code)



requesturi
protected String requesturi(Code)



requesturl
protected StringBuffer requesturl(Code)



savedir
protected String savedir(Code)



servletpath
protected String servletpath(Code)



sessionid
protected String sessionid(Code)



trnpath
protected String trnpath(Code)




Constructor Detail
MultipartRequest
public MultipartRequest(HttpServletRequest request, String saveDirectory) throws IOException(Code)
Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to 1 Megabyte. If the content is too large, an IOException is thrown. This constructor actually parses the multipart/form-data and throws an IOException if there's any problem reading or parsing the request.
Parameters:
  request - the servlet request.
Parameters:
  saveDirectory - the directory in which to save any uploaded files.
exception:
  IOException - if the uploaded content is larger than 1 Megabyteor there's a problem reading or parsing the request.



MultipartRequest
public MultipartRequest(HttpServletRequest request, String saveDirectory, int maxPostSize) throws IOException(Code)
Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to the specified length. If the content is too large, an IOException is thrown. This constructor actually parses the multipart/form-data and throws an IOException if there's any problem reading or parsing the request.
Parameters:
  request - the servlet request.
Parameters:
  saveDirectory - the directory in which to save any uploaded files.
Parameters:
  maxPostSize - the maximum size of the POST content.
exception:
  IOException - if the uploaded content is larger thanmaxPostSize or there's a problem reading or parsing the request.



MultipartRequest
public MultipartRequest(HttpServletRequest request, String saveDirectory, String encoding) throws IOException(Code)
Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to the specified length. If the content is too large, an IOException is thrown. This constructor actually parses the multipart/form-data and throws an IOException if there's any problem reading or parsing the request.
Parameters:
  request - the servlet request.
Parameters:
  saveDirectory - the directory in which to save any uploaded files.
Parameters:
  encoding - the encoding of the response, such as ISO-8859-1
exception:
  IOException - if the uploaded content is larger than1 Megabyte or there's a problem reading or parsing the request.



MultipartRequest
public MultipartRequest(HttpServletRequest request, String saveDirectory, int maxPostSize, FileRenamePolicy policy) throws IOException(Code)
Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to the specified length. If the content is too large, an IOException is thrown. This constructor actually parses the multipart/form-data and throws an IOException if there's any problem reading or parsing the request.
Parameters:
  request - the servlet request.
Parameters:
  saveDirectory - the directory in which to save any uploaded files.
Parameters:
  maxPostSize - the maximum size of the POST content.
Parameters:
  encoding - the encoding of the response, such as ISO-8859-1
exception:
  IOException - if the uploaded content is larger thanmaxPostSize or there's a problem reading or parsing the request.



MultipartRequest
public MultipartRequest(HttpServletRequest request, String saveDirectory, int maxPostSize, String encoding) throws IOException(Code)
Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to the specified length. If the content is too large, an IOException is thrown. This constructor actually parses the multipart/form-data and throws an IOException if there's any problem reading or parsing the request.
Parameters:
  request - the servlet request.
Parameters:
  saveDirectory - the directory in which to save any uploaded files.
Parameters:
  maxPostSize - the maximum size of the POST content.
Parameters:
  encoding - the encoding of the response, such as ISO-8859-1
exception:
  IOException - if the uploaded content is larger thanmaxPostSize or there's a problem reading or parsing the request.



MultipartRequest
public MultipartRequest(HttpServletRequest request, String saveDirectory, int maxPostSize, String encoding, FileRenamePolicy policy) throws IOException(Code)
Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to the specified length. If the content is too large, an IOException is thrown. This constructor actually parses the multipart/form-data and throws an IOException if there's any problem reading or parsing the request. To avoid file collisions, this constructor takes an implementation of the FileRenamePolicy interface to allow a pluggable rename policy.
Parameters:
  request - the servlet request.
Parameters:
  saveDirectory - the directory in which to save any uploaded files.
Parameters:
  maxPostSize - the maximum size of the POST content.
Parameters:
  encoding - the encoding of the response, such as ISO-8859-1
Parameters:
  policy - a pluggable file rename policy
exception:
  IOException - if the uploaded content is larger thanmaxPostSize or there's a problem reading or parsing the request.



MultipartRequest
public MultipartRequest(ServletRequest request, String saveDirectory) throws IOException(Code)
Constructor with an old signature, kept for backward compatibility. Without this constructor, a servlet compiled against a previous version of this class (pre 1.4) would have to be recompiled to link with this version. This constructor supports the linking via the old signature. Callers must simply be careful to pass in an HttpServletRequest.



MultipartRequest
public MultipartRequest(ServletRequest request, String saveDirectory, int maxPostSize) throws IOException(Code)
Constructor with an old signature, kept for backward compatibility. Without this constructor, a servlet compiled against a previous version of this class (pre 1.4) would have to be recompiled to link with this version. This constructor supports the linking via the old signature. Callers must simply be careful to pass in an HttpServletRequest.




Method Detail
getAttribute
public Object getAttribute(String sAttrName)(Code)



getAttributeNames
public Enumeration getAttributeNames()(Code)



getAuthType
public String getAuthType()(Code)



getCharacterEncoding
public String getCharacterEncoding()(Code)



getContentLength
public int getContentLength()(Code)



getContentType
public String getContentType(String name)(Code)
Returns the content type of the specified file (as supplied by the client browser), or null if the file was not included in the upload.
Parameters:
  name - the file name. the content type of the file.



getContentType
public String getContentType()(Code)



getContextPath
public String getContextPath()(Code)



getCookies
public Cookie[] getCookies()(Code)



getDateHeader
public long getDateHeader(String hname)(Code)



getFile
public File getFile(String name)(Code)
Returns a File object for the specified file saved on the server's filesystem, or null if the file was not included in the upload.
Parameters:
  name - the file name. a File object for the named file.



getFile
public File getFile(int number)(Code)
Returns a File object for the specified uploaded file
Parameters:
  number - int [0..getFileCount()-1] File



getFileCount
public int getFileCount()(Code)
number of uploaded files



getFileNames
public Enumeration getFileNames()(Code)
Returns the names of all the uploaded files as an Enumeration of Strings. It returns an empty Enumeration if there are no uploaded files. Each file name is the name specified by the form, not by the user. the names of all the uploaded files as an Enumeration of Strings.



getFilesystemName
public String getFilesystemName(String name)(Code)
Returns the filesystem name of the specified file, or null if the file was not included in the upload. A filesystem name is the name specified by the user. It is also the name under which the file is actually saved.
Parameters:
  name - the file name. the filesystem name of the file.



getHeader
public String getHeader(String hname)(Code)



getHeaderNames
public Enumeration getHeaderNames()(Code)



getHeaders
public Enumeration getHeaders(String hname)(Code)



getInputStream
public ServletInputStream getInputStream()(Code)



getIntHeader
public int getIntHeader(String hname)(Code)



getLocalAddr
public String getLocalAddr()(Code)



getLocalName
public String getLocalName()(Code)



getLocalPort
public int getLocalPort()(Code)



getLocale
public Locale getLocale()(Code)



getLocales
public Enumeration getLocales()(Code)



getMethod
public String getMethod()(Code)



getOriginalFileName
public String getOriginalFileName(String name)(Code)
Returns the original filesystem name of the specified file (before any renaming policy was applied), or null if the file was not included in the upload. A filesystem name is the name specified by the user.
Parameters:
  name - the file name. the original file name of the file.



getParameter
public String getParameter(String name)(Code)
Returns the value of the named parameter as a String, or null if the parameter was not sent or was sent without a value. The value is guaranteed to be in its normal, decoded form. If the parameter has multiple values, only the last one is returned (for backward compatibility). For parameters with multiple values, it's possible the last "value" may be null.
Parameters:
  name - the parameter name. the parameter value.



getParameterMap
public Map getParameterMap()(Code)



getParameterNames
public Enumeration getParameterNames()(Code)
Returns the names of all the parameters as an Enumeration of Strings. It returns an empty Enumeration if there are no parameters. the names of all the parameters as an Enumeration of Strings.



getParameterValues
public String[] getParameterValues(String name)(Code)
Returns the values of the named parameter as a String array, or null if the parameter was not sent. The array has one entry for each parameter field sent. If any field was sent without a value that entry is stored in the array as a null. The values are guaranteed to be in their normal, decoded form. A single value is returned as a one-element array.
Parameters:
  name - the parameter name. the parameter values.



getPathInfo
public String getPathInfo()(Code)



getPathTranslated
public String getPathTranslated()(Code)



getProtocol
public String getProtocol()(Code)



getQueryString
public String getQueryString()(Code)



getReader
public BufferedReader getReader()(Code)



getRealPath
public String getRealPath(String s)(Code)



getRemoteAddr
public String getRemoteAddr()(Code)



getRemoteHost
public String getRemoteHost()(Code)



getRemotePort
public int getRemotePort()(Code)



getRemoteUser
public String getRemoteUser()(Code)



getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String s)(Code)



getRequestURI
public String getRequestURI()(Code)



getRequestURL
public StringBuffer getRequestURL()(Code)



getRequestedSessionId
public String getRequestedSessionId()(Code)



getScheme
public String getScheme()(Code)



getServerName
public String getServerName()(Code)



getServerPort
public int getServerPort()(Code)



getServletPath
public String getServletPath()(Code)

Returns the part of this request's URL that calls the servlet.

Returns the part of this request's URL that calls the servlet. This includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string. Same as the value of the CGI variable SCRIPT_NAME. String containing the name or path of the servlet being called,as specified in the request URL, decoded.



getSession
public HttpSession getSession()(Code)



getSession
public HttpSession getSession(boolean b)(Code)



getUserPrincipal
public Principal getUserPrincipal()(Code)



isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()(Code)



isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()(Code)



isRequestedSessionIdFromUrl
public boolean isRequestedSessionIdFromUrl()(Code)



isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()(Code)



isSecure
public boolean isSecure()(Code)



isUserInRole
public boolean isUserInRole(String role)(Code)



removeAttribute
public void removeAttribute(String sAttrName)(Code)



setAttribute
public void setAttribute(String sAttrName, Object sAttrVal)(Code)



setCharacterEncoding
public void setCharacterEncoding(String sEncoding)(Code)



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.