|
jacquard 1.12.0 by The Web Engineering Factory and Toolworks | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
uk.co.weft.maybeupload.MaybeUploadServlet
A superclass for Servlets which may need to handle file upload. Sun's Servlet class does not transparently handle multipart/form-data requests and, indeed, makes it extremely difficult for application-layer classes to handle them. This class is written as a wrapper round Sun's Servlet class which makes multipart/form-data handling transparent.
This class (and consequently all servlets which are subclasses of this class) know about the following configuration parameters:
allow_overwrite and silently_rename are
false and a name collision occurs, we will throw an
UploadException.
uploadDirPath was "/home/httpd/htdocs/upload",
and the document root of the Web server was
/home/httpd/htdocs, then it would make sense to have
uploadDirURL set to "/upload/"A Optional. No
Default.
NOTE: This code relies heavily on the Tomcat reference implementation and is thus in part Copyright (c) 1999 The Apache Software Foundation. All rights reserved.
"This product includes software developed by the Apache Software Foundation (http://www.apache.org/)."
| Field Summary | |
protected boolean |
allowOverwrite
whether to allow uploaded files to be overwritten when new files are uploaded; default is we don't |
protected int |
maxUpload
the maximum upload size: by default, half a megabyte. |
protected boolean |
saveUploadedFilesToDisk
whether or not to save uploads directly to disk; default is we do |
protected boolean |
silentlyRename
whether or not to rename uploaded files to prevent name collisions; default is we do |
protected java.io.File |
uploadDir
the actual upload directory as a file object |
protected java.lang.String |
uploadDirPath
file system local path to where I unpack files I have uploaded |
protected java.lang.String |
uploadDirURL
the path to my upload directory (work directory) within the document root of the web server, if it is within the document root of the web server, else null. |
| Constructor Summary | |
MaybeUploadServlet()
|
|
| Method Summary | |
protected void |
doDelete(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
Simple wrapper round HttpServlet.doDelete( ), so that you can depend on having a MaybeUploadRequestWrapper in your code. |
protected void |
doGet(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
Simple wrapper round HttpServlet.doGet( ), so that you can depend on having a MaybeUploadRequestWrapper in your code. |
protected void |
doHead(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
doHead is a bit more tricky. |
protected void |
doOptions(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
Simple wrapper round HttpServlet.doOptions( ), so that you can depend on having a MaybeUploadRequestWrapper in your code. |
protected void |
doPost(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
Simple wrapper round HttpServlet.doPost( ), so that you can depend on having a MaybeUploadRequestWrapper in your code. |
protected void |
doPut(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
Simple wrapper round HttpServlet.doPut( ), so that you can depend on having a MaybeUploadRequestWrapper in your code. |
protected void |
doTrace(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
Simple wrapper round HttpServlet.doTrace( ), so that you can depend on having a MaybeUploadRequestWrapper in your code. |
java.io.File |
getUploadDir()
|
java.lang.String |
getUploadURL()
|
void |
init(javax.servlet.ServletConfig config)
initialise my variables from my configuration |
void |
service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
Service a request. |
| Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service |
| Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.io.File uploadDir
protected java.lang.String uploadDirPath
protected java.lang.String uploadDirURL
uploadDirPath was
"/home/httpd/htdocs/upload", and the document root of the
Web server was /home/httpd/htdocs, then it would make
sense to have uploadDirURL set to "/upload/"
protected boolean allowOverwrite
protected boolean saveUploadedFilesToDisk
protected boolean silentlyRename
protected int maxUpload
| Constructor Detail |
public MaybeUploadServlet()
| Method Detail |
public java.io.File getUploadDir()
public java.lang.String getUploadURL()
public void init(javax.servlet.ServletConfig config)
throws javax.servlet.ServletException
config - my configuration
javax.servlet.ServletException - doesn't; thing which specialise me may
javax.servlet.UnavailableException - if can't write to upload directory
public void service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
req - the request to be servicedresp - the response being constructed to this request
javax.servlet.ServletException
java.io.IOException
protected void doDelete(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
req - a request wrapper which know how to handle uploadresp - a standard servlet response
javax.servlet.ServletException
java.io.IOException
protected void doGet(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
req - a request wrapper which know how to handle uploadresp - a standard servlet response
javax.servlet.ServletException
java.io.IOException
protected void doHead(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
req - a request wrapper which know how to handle uploadresp - a standard servlet response
javax.servlet.ServletException
java.io.IOException
protected void doOptions(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
req - a request wrapper which know how to handle uploadresp - a standard servlet response
javax.servlet.ServletException
java.io.IOException
protected void doPost(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
req - a request wrapper which know how to handle uploadresp - a standard servlet response
javax.servlet.ServletException
java.io.IOException
protected void doPut(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
req - a request wrapper which know how to handle uploadresp - a standard servlet response
javax.servlet.ServletException
java.io.IOException
protected void doTrace(MaybeUploadRequestWrapper req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
req - a request wrapper which know how to handle uploadresp - a standard servlet response
javax.servlet.ServletException
java.io.IOException
|
jacquard 1.12.0 by The Web Engineering Factory and Toolworks | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||