public class ThisPage extends Object
UploadServlet.ThisPage
Modifier and Type | Field and Description |
---|---|
protected ServletConfig |
config
Servlet configuration.
|
protected byte[] |
contents
The byte array contains the contents of the document to be displayed.
|
protected ServletContext |
context
Application (context) configuration.
|
protected DatabaseProperties |
data
Used to pass information on database connection.
|
protected int |
debugLevel
Controls amount of diagnostic output.
|
static int |
DOWNLOAD
Indicates that the document should be downloaded to the
client machine.
|
protected Date |
endDate
Ending date of date range.
|
protected String |
fileName
File name to be associated with the download.
|
protected ServletInputStream |
input
Input stream from HTTP request.
|
protected Vector<String> |
messageList
A list of warning or error messages that will appear
on the web page generated by the servlet.
|
protected String |
mimeType
Contains the MIME code for the document to be displayed.
|
protected int |
mode
Indicates the mode of operation.
|
static int |
NORMAL
Indicates that the document should be displayed in the browser if
possible.
|
private ServletOutputStream |
outputStream
Object for sending information to HTTP response
as a binary stream.
|
private GenericPrinter |
printer
This is the printer object that will be used by servlet code.
|
protected String |
redirectAddress
Address to be used for redirecting servlet.
|
private HttpServletRequest |
request
Request object.
|
private HttpServletResponse |
response
Response object.
|
protected Date |
startDate
Starting date of date range.
|
private StringWriter |
stringWriter
Used internally to store information for page.
|
protected boolean |
terminateRequest
Cancel processing if set to true.
|
private PrintWriter |
writer
PrintWriter object for response.
|
Constructor and Description |
---|
ThisPage()
Default constructor added to allow subclassing.
|
ThisPage(HttpServletRequest requestValue,
HttpServletResponse responseValue,
ServletConfig configValue) |
Modifier and Type | Method and Description |
---|---|
void |
addException(Exception e)
Adds a description of an exception to the list
of messages for the error page.
|
void |
addMessage(String value)
Add a message to the list of messages for the
error page.
|
void |
clearWriter()
Clear the contents of the StringWriter object.
|
void |
errorMessage()
Generates an error page based on the calls to the
addMessage and addException methods.
|
ServletConfig |
getConfig()
Get servlet configuration.
|
byte[] |
getContents()
Get the byte array to be used to display the downloaded item.
|
ServletContext |
getContext()
Get application context.
|
DatabaseProperties |
getDatabase()
Get the object containing database connection properties.
|
int |
getDebugLevel()
Gets value of debugLevel.
|
Date |
getEndDate()
Return end date of date range.
|
String |
getFileName()
Get the filename associated with the item to be downloaded.
|
ServletInputStream |
getInputStream()
Return the input object obtaining information from the
HTTP request.
|
Vector<String> |
getMessageList()
Returns list of messages for the error page.
|
String |
getMimeType()
Get the MIME code for the document.
|
int |
getMode()
Get the mode of operation.
|
ServletOutputStream |
getOutputStream()
Obtain the output stream for sending information to the
browser as a stream of bytes.
|
GenericPrinter |
getPrinter()
Get the generic printer object.
|
String |
getRedirectAddress()
Get redirectAddress.
|
HttpServletRequest |
getRequest()
Gets request object.
|
HttpServletResponse |
getResponse()
Gets response object.
|
Date |
getStartDate()
Return start date for date range.
|
boolean |
getTerminateRequest()
Get the value of terminateRequest
|
protected PrintWriter |
getWriter()
Obtains the PrintWriter object for sending the page contents
as a character string.
|
void |
sendContents()
Send the contents of the StringWriter object to
the response object.
|
void |
setContents(byte[] value)
Set the byte array to be used to display the downloaded item.
|
void |
setDatabase(DatabaseProperties databaseValue)
Set the object containing database connection properties.
|
void |
setDebugLevel(int value)
Sets value of debugLevel
|
void |
setEndDate(Date value)
Set end date of date range.
|
void |
setFileName(String value)
Set the filename associated with the item to be downloaded.
|
void |
setMimeType(String value)
Set the MIME code for the document.
|
void |
setMode(int value)
Set the mode of operation
|
void |
setRedirectAddress(String value)
Set redirectAddress.
|
void |
setStartDate(Date value)
Set start date of date range.
|
private HttpServletRequest request
private HttpServletResponse response
protected ServletConfig config
protected ServletContext context
protected ServletInputStream input
getInputStream()
protected DatabaseProperties data
setDatabase(DatabaseProperties)
,
getDatabase()
protected Date startDate
setStartDate(Date)
,
getStartDate()
protected Date endDate
setEndDate(Date)
,
getEndDate()
private PrintWriter writer
The value is only set when the method
getWriter()
is called.
getWriter()
private StringWriter stringWriter
private GenericPrinter printer
The material is passed to a StringWriter that can be cleared and rewritten before sending the material to the response object.
getPrinter()
private ServletOutputStream outputStream
getOutputStream()
protected Vector<String> messageList
The text of the messages are processed by
StringHelpers.escapeHTML(String)
before
being sent to the web page. The surrounding tags
will also have to be added.
The error page is generated by calling
errorMessage()
.
protected boolean terminateRequest
The flag is set when
errorMessage()
or sendContents()
is called.
protected int debugLevel
More positive values mean more diagnostic listings.
public static final int NORMAL
mode
,
Constant Field Valuespublic static final int DOWNLOAD
mode
,
Constant Field Valuesprotected int mode
protected byte[] contents
protected String redirectAddress
public ThisPage()
public ThisPage(HttpServletRequest requestValue, HttpServletResponse responseValue, ServletConfig configValue) throws IOException
IOException
public boolean getTerminateRequest()
terminateRequest
public void clearWriter()
protected PrintWriter getWriter() throws IOException
The only public means of calling this method is to use
sendContents()
.
IOException
public void sendContents() throws IOException
IOException
public void setDatabase(DatabaseProperties databaseValue)
databaseValue
- Object containing database propertiesdata
public DatabaseProperties getDatabase()
data
public HttpServletRequest getRequest()
public HttpServletResponse getResponse()
public ServletConfig getConfig()
Parameters that are specified for a single servlet belong to this object.
public ServletContext getContext()
Parameters that belong to the entire application belong to this object.
context
public ServletInputStream getInputStream()
input
public ServletOutputStream getOutputStream() throws IOException
If this method is called,
the sendContents()
and errorMessage()
messages can not be used.
IOException
public GenericPrinter getPrinter()
printer
public Vector<String> getMessageList()
public void addMessage(String value)
value
- Message to be addedmessageList
public void addException(Exception e)
e
- Exception to be describedmessageList
public void errorMessage() throws IOException
IOException
addMessage(String)
,
addException(Exception)
public void setStartDate(Date value)
value
- Date to be used for start of date rangestartDate
public Date getStartDate()
startDate
public void setEndDate(Date value)
value
- Date to be used for end of date rangeendDate
public Date getEndDate()
endDate
public int getDebugLevel()
debugLevel
public void setDebugLevel(int value)
value
- Value to be useddebugLevel
public void setMimeType(String value)
value
- MIME codepublic String getMimeType()
public void setFileName(String value)
value
- File namepublic String getFileName()
public byte[] getContents()
public void setContents(byte[] value)
value
- Contents of downloaded itempublic void setMode(int value) throws IOException
value
- Mode of operationIOException
public int getMode()
public void setRedirectAddress(String value)
value
- Value to be usedredirectAddress
public String getRedirectAddress()
redirectAddress