|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.ibm.wbi.Meg
|
+--com.ibm.wbi.Generator
|
+--com.ibm.wbi.protocol.http.HttpGenerator
|
+--com.ibm.wbi.protocol.http.beans.FourStepHttpGenerator
|
+--com.ibm.wbi.protocol.http.beans.FileGenerator
A Generator for delivering the contents of a file to the client. This class has several properties (some of which are defined by the superclass). For normal operation, the most used properties are Filename and ContentType. These specify the name of the file to be served (either absolute filepath, or relative to the working directory) and the MIME type to be reported back to the browser.
The ContentType property is set automatically based on the filename extension, if the extension is known. It can always be set to a different value with the setContentType(...) method.
The DefaultFile property is used to redirect a browser to a default file within a directory if the specified filename is itself a directory. If DefaultFile is null, a null string, or points to a non-existent file, this property is ignored.
The ShowDirectories property, when set to true (the default is false), means that Filenames which point to directories will be presented as HTML renditions of directories, with links to the subdirectories and files within the directories. Note that this may be security issue (which is why the property defaults to false).
The LinkToParentDirectory property, when set to true (the default is false), means that HTML renditions of directories will contain a link to the ".." directory, the parent of the current directory. When set to false, this link will not be shown.
By default, the browser is allowed to cache the document. This property can be adjusted with the setCache(boolean) and isCache() methods of the superclass.
| Field Summary | |
static java.lang.String |
COPYRIGHT
IBM copyright information |
| Fields inherited from class com.ibm.wbi.protocol.http.HttpGenerator |
http |
| Fields inherited from class com.ibm.wbi.Meg |
EDITOR, GENERATOR, MONITOR, REQUEST_EDITOR, UNDEFINED |
| Constructor Summary | |
FileGenerator()
Construct an instance with a null Filename, a default "text/html" ContentType, a DefaultFile of "index.html", and not to show directory contents. |
|
FileGenerator(java.lang.String filename)
Construct an instance with the given Filename and not to show directory contents. |
|
FileGenerator(java.lang.String filename,
java.lang.String type)
Construct an instance with the given Filename and ContentType. |
|
| Method Summary | |
java.lang.String |
getDefaultFile()
Access the DefaultFile property. |
java.lang.String |
getFilename()
Access the Filename property |
boolean |
isLinkToParentDirectory()
Access the LinkToParentDirectory property. |
boolean |
isShowDirectories()
Access the ShowDirectories property. |
void |
setContentType(java.lang.String ct)
Override the inherited method. |
void |
setDefaultFile(java.lang.String df)
Set the DefaultFile property. |
void |
setFilename(java.lang.String fn)
set the Filename property with the name of the file to be served, (either an absolute filepath, or relative to the WBI working directory). |
void |
setLinkToParentDirectory(boolean ltpd)
Set the LinkToParentDirectory property. |
void |
setShowDirectories(boolean sd)
Set the ShowDirectories property. |
protected boolean |
verify(RequestEvent e)
Determine if file exists. |
protected void |
writeContent(RequestEvent e)
Write the file's contents to the stream. |
| Methods inherited from class com.ibm.wbi.protocol.http.beans.FourStepHttpGenerator |
getHeader, handleRequest, initialize |
| Methods inherited from class com.ibm.wbi.protocol.http.HttpGenerator |
add, addCookie, getContentType, getHttpResponse, getHttpResponseString, getResponseCode, getResponseText, isCache, produceHeader, set, setCache, setContentLength, setResponseCode, setResponseText, setServer, writeHeader |
| Methods inherited from class com.ibm.wbi.Generator |
getType |
| Methods inherited from class com.ibm.wbi.Meg |
forwardRequest, getCondition, getEnabled, getMegProperty, getMegProperty, getMegPropertyKeys, getName, getPlugin, getPriority, getSystemContext, initialize, initialize, isEnabled, isMegApplicable, loadMegResources, run, setCondition, setEnabled, setMegProperty, setName, setPriority, setSystemContext, setup, setup, setup, setup |
| Field Detail |
public static final java.lang.String COPYRIGHT
| Constructor Detail |
public FileGenerator()
public FileGenerator(java.lang.String filename)
filename - The name of the file to be served.setFilename(String)
public FileGenerator(java.lang.String filename,
java.lang.String type)
filename - The name of the file to be servedtype - The MIME type to be reported back to the browser. If null, the
MIME type is derived from the filename extension (e.g. ".jpg" becomes "image/jpeg")setFilename(String)| Method Detail |
public void setFilename(java.lang.String fn)
The ContentType is automatically determined from the filename extension, but may be overridden with the setContentType(...) method. If the filename extension is unknown, the ContentType property is left unchanged.
fn - The Filenamepublic java.lang.String getFilename()
public void setShowDirectories(boolean sd)
public void setContentType(java.lang.String ct)
setContentType in class HttpGeneratorcom.ibm.wbi.protocol.http.HttpGeneratorct - The ContentType.HttpBase.setContentType(java.lang.String)public boolean isShowDirectories()
public void setLinkToParentDirectory(boolean ltpd)
public boolean isLinkToParentDirectory()
public void setDefaultFile(java.lang.String df)
public java.lang.String getDefaultFile()
protected boolean verify(RequestEvent e)
verify in class FourStepHttpGeneratore - The request event.
protected void writeContent(RequestEvent e)
throws RequestRejectedException,
java.io.IOException
writeContent in class FourStepHttpGenerator
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||