Top Description Methods
javax.servlet.http

public Interface Part

Imports
java.io.*, java.util.*

This class represents a part or form item that was received within a multipart/form-data POST request.

Since
Servlet 3.0

Method Summary

Modifier and TypeMethod and Description
public void
delete()

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

public String

Returns:

The content type of this part.
getContentType
()

Gets the content type of this part.

public String

Returns:

a String containing the value of the requested header, or null if the part does not have a header of that name
getHeader
(String
a String specifying the header name
name
)

Returns the value of the specified mime header as a String.

public Collection<String>

Returns:

a (possibly empty) Collection of the header names of this Part
getHeaderNames
()

Gets the header names of this Part.

public Collection<String>

Returns:

a (possibly empty) Collection of the values of the header with the given name
getHeaders
(String
the header name whose values to return
name
)

Gets the values of the Part header with the given name.

public InputStream

Returns:

The content of this part as an InputStream
getInputStream
()

Gets the content of this part as an InputStream

public String

Returns:

The name of this part as a String
getName
()

Gets the name of this part

public long

Returns:

a long specifying the size of this part, in bytes.
getSize
()

Returns the size of this fille.

public String

Returns:

the submitted file name
getSubmittedFileName
()

Gets the file name specified by the client

public void
write(String
The location into which the uploaded part should be stored. The value may be a file name or a path. The actual location of the file in the filesystem is relative to javax.servlet.MultipartConfigElement#getLocation(). Absolute paths are used as provided and are relative to getLocation().

Note

that this is a system dependent string and URI notation may not be acceptable on all systems. For portability, this string should be generated with the File or Path APIs.

fileName
)

A convenience method to write this uploaded item to disk.

Method Detail

deleteback to summary
public void delete() throws IOException

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

Exceptions
IOException:
if an error occurs.
getContentTypeback to summary
public String getContentType()

Gets the content type of this part.

Returns:String

The content type of this part.

getHeaderback to summary
public String getHeader(String name)

Returns the value of the specified mime header as a String. If the Part did not include a header of the specified name, this method returns null. If there are multiple headers with the same name, this method returns the first header in the part. The header name is case insensitive. You can use this method with any request header.

Parameters
name:String

a String specifying the header name

Returns:String

a String containing the value of the requested header, or null if the part does not have a header of that name

getHeaderNamesback to summary
public Collection<String> getHeaderNames()

Gets the header names of this Part.

Some servlet containers do not allow servlets to access headers using this method, in which case this method returns null

Any changes to the returned Collection must not affect this Part.

Returns:Collection<String>

a (possibly empty) Collection of the header names of this Part

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

Gets the values of the Part header with the given name.

Any changes to the returned Collection must not affect this Part.

Part header names are case insensitive.

Parameters
name:String

the header name whose values to return

Returns:Collection<String>

a (possibly empty) Collection of the values of the header with the given name

getInputStreamback to summary
public InputStream getInputStream() throws IOException

Gets the content of this part as an InputStream

Returns:InputStream

The content of this part as an InputStream

Exceptions
IOException:
If an error occurs in retrieving the content as an InputStream
getNameback to summary
public String getName()

Gets the name of this part

Returns:String

The name of this part as a String

getSizeback to summary
public long getSize()

Returns the size of this fille.

Returns:long

a long specifying the size of this part, in bytes.

getSubmittedFileNameback to summary
public String getSubmittedFileName()

Gets the file name specified by the client

Returns:String

the submitted file name

Since
Servlet 3.1
writeback to summary
public void write(String fileName) throws IOException

A convenience method to write this uploaded item to disk.

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. The value may be a file name or a path. The actual location of the file in the filesystem is relative to javax.servlet.MultipartConfigElement#getLocation(). Absolute paths are used as provided and are relative to getLocation().

Note

that this is a system dependent string and URI notation may not be acceptable on all systems. For portability, this string should be generated with the File or Path APIs.

Exceptions
IOException:
if an error occurs.