Top Description Fields Constructors Methods
org.apache.catalina.core

public Class ApplicationPart

extends Object
implements Part
Class Inheritance
All Implemented Interfaces
jakarta.servlet.http.Part
Imports
java.io.File, .IOException, .InputStream, .UnsupportedEncodingException, java.util.Collection, .Collections, .Iterator, .LinkedHashSet, .Locale, .Map, jakarta.servlet.http.Part, org.apache.tomcat.util.http.fileupload.FileItem, .ParameterParser, org.apache.tomcat.util.http.fileupload.disk.DiskFileItem, org.apache.tomcat.util.http.parser.HttpParser

Adaptor to allow FileItem objects generated by the package renamed commons-upload to be used by the Servlet 3.0 upload API that expects Parts.

Field Summary

Modifier and TypeField and Description
private final FileItem
private final File

Constructor Summary

AccessConstructor and Description
public
ApplicationPart(FileItem fileItem, File location)

Method Summary

Modifier and TypeMethod and Description
public void
delete()

Implements jakarta.servlet.http.Part.delete.

Deletes the underlying storage for a part, including deleting any associated temporary disk file.

public String
getContentType()

Implements jakarta.servlet.http.Part.getContentType.

Obtain the content type passed by the browser.

public String
getHeader(String
Header name
name
)

Implements jakarta.servlet.http.Part.getHeader.

Obtains the value of the specified part header as a String.

public Collection<String>
getHeaderNames()

Implements jakarta.servlet.http.Part.getHeaderNames.

Get the header names provided for this part.

public Collection<String>
getHeaders(String
The name of the header of interest. The header name is case insensitive.
name
)

Implements jakarta.servlet.http.Part.getHeaders.

Obtain all the values of the specified part header.

public InputStream
getInputStream()

Implements jakarta.servlet.http.Part.getInputStream.

Obtain an InputStream that can be used to retrieve the contents of the file.

public String
getName()

Implements jakarta.servlet.http.Part.getName.

Obtain the name of the field in the multipart form corresponding to this part.

public long
getSize()

Implements jakarta.servlet.http.Part.getSize.

Obtain the size of this part.

public String
getString(String encoding)

public String
getSubmittedFileName()

Implements jakarta.servlet.http.Part.getSubmittedFileName.

If this part represents an uploaded file, gets the file name submitted in the upload.

public void
write(String
The location into which the uploaded part should be stored. Relative locations are relative to jakarta.servlet.MultipartConfigElement#getLocation()
fileName
)

Implements jakarta.servlet.http.Part.write.

A convenience method to write an uploaded part to disk.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileItemback to summary
private final FileItem fileItem
locationback to summary
private final File location

Constructor Detail

ApplicationPartback to summary
public ApplicationPart(FileItem fileItem, File location)

Method Detail

deleteback to summary
public void delete() throws IOException

Implements jakarta.servlet.http.Part.delete.

Doc from jakarta.servlet.http.Part.delete.

Deletes the underlying storage for a part, including deleting any associated temporary disk file. Although the container will delete this storage automatically this method can be used to ensure that this is done at an earlier time, thus preserving system resources.

Containers are only required to delete the associated storage when the Part instance is garbage collected. Apache Tomcat will delete the associated storage when the associated request has finished processing. Behaviour of other containers may be different.

Annotations
@Override
Exceptions
IOException:
if an I/O occurs while attempting to delete the part
getContentTypeback to summary
public String getContentType()

Implements jakarta.servlet.http.Part.getContentType.

Doc from jakarta.servlet.http.Part.getContentType.

Obtain the content type passed by the browser.

Returns:String

The content type passed by the browser or null if not defined.

Annotations
@Override
getHeaderback to summary
public String getHeader(String name)

Implements jakarta.servlet.http.Part.getHeader.

Doc from jakarta.servlet.http.Part.getHeader.

Obtains the value of the specified part header as a String. If there are multiple headers with the same name, this method returns the first header in the part. The header name is case insensitive.

Parameters
name:String

Header name

Returns:String

The header value or null if the header is not present

Annotations
@Override
getHeaderNamesback to summary
public Collection<String> getHeaderNames()

Implements jakarta.servlet.http.Part.getHeaderNames.

Doc from jakarta.servlet.http.Part.getHeaderNames.

Get the header names provided for this part.

Returns:Collection<String>

a Collection of all the header names provided for this part.

Annotations
@Override
getHeadersback to summary
public Collection<String> getHeaders(String name)

Implements jakarta.servlet.http.Part.getHeaders.

Doc from jakarta.servlet.http.Part.getHeaders.

Obtain all the values of the specified part header.

Parameters
name:String

The name of the header of interest. The header name is case insensitive.

Returns:Collection<String>

All the values of the specified part header. If the part did not include any headers of the specified name, this method returns an empty Collection.

Annotations
@Override
getInputStreamback to summary
public InputStream getInputStream() throws IOException

Implements jakarta.servlet.http.Part.getInputStream.

Doc from jakarta.servlet.http.Part.getInputStream.

Obtain an InputStream that can be used to retrieve the contents of the file.

Returns:InputStream

An InputStream for the contents of the file

Annotations
@Override
Exceptions
IOException:
if an I/O occurs while obtaining the stream
getNameback to summary
public String getName()

Implements jakarta.servlet.http.Part.getName.

Doc from jakarta.servlet.http.Part.getName.

Obtain the name of the field in the multipart form corresponding to this part.

Returns:String

The name of the field in the multipart form corresponding to this part.

Annotations
@Override
getSizeback to summary
public long getSize()

Implements jakarta.servlet.http.Part.getSize.

Doc from jakarta.servlet.http.Part.getSize.

Obtain the size of this part.

Returns:long

The size of the part if bytes

Annotations
@Override
getStringback to summary
public String getString(String encoding) throws UnsupportedEncodingException, IOException
getSubmittedFileNameback to summary
public String getSubmittedFileName()

Implements jakarta.servlet.http.Part.getSubmittedFileName.

Doc from jakarta.servlet.http.Part.getSubmittedFileName.

If this part represents an uploaded file, gets the file name submitted in the upload. Returns null if no file name is available or if this part is not a file upload.

Returns:String

the submitted file name or null.

Annotations
@Override
writeback to summary
public void write(String fileName) throws IOException

Implements jakarta.servlet.http.Part.write.

Doc from jakarta.servlet.http.Part.write.

A convenience method to write an uploaded part to disk. The client code is not concerned with whether or not the part is stored in memory, or on disk in a temporary location. They just want to write the uploaded part to a file. This method is not guaranteed to succeed if called more than once for the same part. This allows a particular implementation to use, for example, file renaming, where possible, rather than copying all of the underlying data, thus gaining a significant performance benefit.

Parameters
fileName:String

The location into which the uploaded part should be stored. Relative locations are relative to jakarta.servlet.MultipartConfigElement#getLocation()

Annotations
@Override
Exceptions
IOException:
if an I/O occurs while attempting to write the part