SK.gnome.dwarf.http.servlet
Class UploadServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
SK.gnome.dwarf.http.servlet.UploadServlet
- All Implemented Interfaces:
- java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
- public class UploadServlet
- extends javax.servlet.http.HttpServlet
This servlet handles the form-based file uploads.
To upload a file to the server via the HTTP protocol you can use this servlet. The servlet
should be invoked from a special HTML form. The <form ...> HTML element must have
the action attribute equal to "POST" and the enctype attribute equal
to "multipart/form-data". One of the form input fields must be of type file
with its name attribute equal to "localFile" string.
The following parameters can be provided to UploadServlet, either via the
query string or via the form input elements:
- remoteDir - this parameter is required and specifies the directory to which
the uploaded file will be saved on the server side
- remoteFile - this optional parameter specifies the file name to use for
saving the uploaded file. If not specified, the original file
name (sent by the browser) will be used.
- successPage - this parameter is required and specifies URI path of the page
to be sent to the client after successful upload
- errorPage - this parameter is optional and specifies URI path of an error
page. This page is sent to the client in the case of a failed
upload. The message parameter is provided to the error
page via the query string with a detailed error description.
A typicall file-uploading form might look like this:
<form method="POST" action="/upload" enctype="multipart/form-data">
<input type="hidden" name="remoteDir" value="/tmp">
<input type="hidden" name="successPage" value="/upload_ok.html">
<input type="hidden" name="errorPage" value="/upload_error.html">
<input type="file" name="localFile">
<input type="submit" name="submit" value="OK">
</form>
After the server processes the multipart/form-data request body the following
information can be obtained from the request, assuming that the file form input
element is named "localFile":
- parameter "localFile.file-name" - the name of the uploaded file
- parameter "localFile.content-type" - the content type of the uploaded file
- attribute "localFile.content" - the java.io.File object representing the
uploaded file
- See Also:
- Serialized Form
Method Summary |
protected void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
java.lang.String |
getServletInfo()
|
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doGet, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UploadServlet
public UploadServlet()
getServletInfo
public java.lang.String getServletInfo()
doPost
protected void doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException,
javax.servlet.ServletException
- Throws:
java.io.IOException
javax.servlet.ServletException
Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.