|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.sandev.tools.HTTP.ServletInput
public class ServletInput
Provides access to the HttpServletRequest parameter map.
Under standard form submission, the content type of the request is
application/x-www-form-urlencoded
multipart/form-data; boundary=---------------------------7d426931f0198
Here's how this works:
uploadedimage, or because the form
definition was manually transformed to type="file".
The user selects a file to upload, and the contents are submitted
back triggered by the enctype="multipart/form-data".
The default rendering sets the encoding type if it finds a
containing span of type uploadedimage/file.
XHTMLSandUIServlet sets the
SANDUploadDirectory request attribute to the value of
UIFormAdaptorCallback.getInboundFilesDir(). In a
typical approach, this is set to a relative path off the default
runtime directory. In a production environment, this directory
would be symlinked to a networked area with backup.
XHTMLSandUIServlet also calls
UIFormAdaptorCallback.setInboundFilesDir() so that
uploaded filenames can be trapped and converted into their
corresponding href in
UIFormAdaptorCallback.filterDisplayText.
Files are uploaded without any type or size checking. Since this is for authorized users only, it didn't seem worth the extra work necessary on this pass. The next step would be to provide a setFileTypes(String[]) method to set the allowed MIME file types. That means extending the UIRenderInput interface with this declaration, and sourcing the values from the SandUI definition at runtime.
| Field Summary | |
|---|---|
protected java.util.Map |
paramMap
Our map of the form parameters. |
| Constructor Summary | |
|---|---|
ServletInput()
|
|
| Method Summary | |
|---|---|
protected void |
addExistingParamsToMap(javax.servlet.http.HttpServletRequest req)
The standard HttpServletRequest map is immutable, so we typically make a copy to pass additional useful information. |
protected void |
echoRequest(javax.servlet.http.HttpServletRequest req)
Dump a copy of the incoming request. |
protected java.lang.String |
getAttributeValue(java.lang.String attrName,
java.lang.String text)
Given a string with an html attribute value in it, and the attribute name, return the value or null if not found. |
protected java.lang.String |
getBoundary(java.lang.String line)
Given a content text type specification, return the boundary text. |
java.util.Map |
getInputParameters()
|
void |
init(java.lang.Object req)
The initialization object in this case is an HttpServletRequest |
protected java.lang.String |
readFileContents(javax.servlet.ServletInputStream in,
java.lang.String boundary,
java.lang.String filename,
java.lang.String path)
Read the contents into a new file, returning the new file name. |
protected java.lang.String |
readLine(javax.servlet.ServletInputStream in)
Read a line of input from the input stream and return it minus the terminating CRLF. |
protected java.lang.String |
readParameterValue(javax.servlet.ServletInputStream in,
java.lang.String boundary)
Read a parameter value from the input stream. |
protected void |
readToContents(javax.servlet.ServletInputStream in)
Read lines until we hit an empty line. |
protected java.lang.String |
readToLine(javax.servlet.ServletInputStream in,
java.lang.String linePrefix)
Read lines until reading one starting with the specified prefix. |
protected void |
uploadAndBuildMap(java.lang.String boundary,
javax.servlet.http.HttpServletRequest req)
Given a multipart form request, upload the file and reconstruct the parameter map. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.util.Map paramMap
| Constructor Detail |
|---|
public ServletInput()
| Method Detail |
|---|
public void init(java.lang.Object req)
init in interface org.sandev.basics.util.UIRenderOperandpublic java.util.Map getInputParameters()
getInputParameters in interface org.sandev.basics.util.UIRenderInputprotected void addExistingParamsToMap(javax.servlet.http.HttpServletRequest req)
protected void echoRequest(javax.servlet.http.HttpServletRequest req)
protected java.lang.String getBoundary(java.lang.String line)
multipart/form-data; boundary=---------------------------7d426931f0198
protected java.lang.String readLine(javax.servlet.ServletInputStream in)
throws java.io.IOException
java.io.IOException
protected java.lang.String readToLine(javax.servlet.ServletInputStream in,
java.lang.String linePrefix)
throws java.io.IOException
java.io.IOException
protected java.lang.String getAttributeValue(java.lang.String attrName,
java.lang.String text)
Content-Disposition: form-data; name="MyForm.form_action"
MyForm.form_action. If asked for
"foo" from the same text, then this method returns null.
If the attribute is found, this method returns the interned string value, so the result can be safely used as a hash key.
protected void readToContents(javax.servlet.ServletInputStream in)
throws java.io.IOException
java.io.IOException
protected void uploadAndBuildMap(java.lang.String boundary,
javax.servlet.http.HttpServletRequest req)
protected java.lang.String readFileContents(javax.servlet.ServletInputStream in,
java.lang.String boundary,
java.lang.String filename,
java.lang.String path)
throws java.io.IOException
java.io.IOException
protected java.lang.String readParameterValue(javax.servlet.ServletInputStream in,
java.lang.String boundary)
throws java.io.IOException
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||