|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.servlet.util.StreamContentServlet
public class StreamContentServlet
The StreamContentServlet servlet is used to deliver arbitrary MIME type content to HTTP clients.
In order to deliver content back to the client, the StreamContentServlet requires that the certain attributes
be available on either the request or session object. If the CONTENT_KEY request parameter is set, then all
other attributes must be set on the session using setAttribute. If it is not set, then they must be set on the
request using setAttribute. The value of CONTENT_KEY is prepended to other attributes below to uniquely identify
the content request.
Name of static class fields | String value | Use | Required |
---|---|---|---|
CONTENT_TYPE | sas_StreamContentServlet _ContentType | specifies the MIME type of the content. Used as the parameter to the response.setContentType() method. | Yes |
CONTENT_DISPOSITION | sas_StreamContentServlet_ContentDisposition | specifies the value to be used to set the Content-Disposition response header field. | No |
CONTENT_BYTES | sas_StreamContentServlet_ContentBytes | specifies the content to be streamed back to the user. | Yes |
DISPOSE_CONTENTS | sas_StreamContentServlet_DisposeContents | specifies whether ot not to remove the attributes from the session after use. | No |
Example using CONTENT_KEY and session attributes:
<%@page import="com.sas.servlet.util.*"%> <% byte [] b = //get your bytes here String src = "testgif"; String url = "/mywebapp/StreamContentServlet?"+ StreamContentServlet.CONTENT_KEY + "=" + src; session.setAttribute(StreamContentServlet.CONTENT_TYPE + src, "image/gif"); session.setAttribute(StreamContentServlet.CONTENT_BYTES + src, bb); session.setAttribute(StreamContentServlet.CONTENT_DISPOSITION + src, "inline;filename=test.gif"); %> <img src="<%=url%>"/> Example using request attributes:
<%@page import="com.sas.servlet.util.*"%> <% byte [] b = //get your bytes here String url = "/mywebapp/StreamContentServlet?"; request.setAttribute(StreamContentServlet.CONTENT_TYPE, "image/gif"); request.setAttribute(StreamContentServlet.CONTENT_BYTES, b); request.setAttribute(StreamContentServlet.CONTENT_DISPOSITION, "inline;filename=test.gif"); %> <img src="<%=url%>"/>
In order to use the StreamContentServlet, you may need to register the servlet with the application server that you are deploying on. Please refer to the Deploying AppDev Studio Web Applications on Specific Application Servers section of the document entitled Web Application Deployment Tips and Tricks for more information on how to register the StreamContentServlet.
StreamContent
,
Serialized FormField Summary | |
---|---|
static java.lang.String |
CONTENT_BYTES
The attribute key which stores the content bytes on the request or session. |
static java.lang.String |
CONTENT_DISPOSITION
The attribute key which stores the content disposition on the request or session. |
static java.lang.String |
CONTENT_KEY
The attribute key under which the servlet stores and retrieves request and session data. |
static java.lang.String |
CONTENT_TYPE
The attribute key which stores the content type on the request or session. |
static java.lang.String |
DISPOSE_CONTENTS
The attribute key which stores the dispose contents value on the request or session. |
static java.lang.String |
NOOP
The parameter which is set to perform a noop. |
static java.lang.String |
PERSISTENCE
The parameter which is set to disable connection persistence. |
static java.lang.String |
RB_KEY
ResourceBundle key. |
Constructor Summary | |
---|---|
StreamContentServlet()
|
Method Summary | |
---|---|
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Overrides doGet in javax.servlet.http.HttpServlet |
void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Overrides doPost in javax.servlet.http.HttpServlet |
java.lang.String |
getServletInfo()
Overrides the getServletInfo() defined by javax.servlet.http.HttpServlet. |
Field Detail |
---|
public static final java.lang.String CONTENT_KEY
public static final java.lang.String PERSISTENCE
public static final java.lang.String NOOP
public static final java.lang.String CONTENT_TYPE
public static final java.lang.String CONTENT_DISPOSITION
public static final java.lang.String CONTENT_BYTES
public static final java.lang.String DISPOSE_CONTENTS
public static final java.lang.String RB_KEY
Constructor Detail |
---|
public StreamContentServlet()
Method Detail |
---|
public java.lang.String getServletInfo()
getServletInfo
in interface javax.servlet.Servlet
getServletInfo
in class javax.servlet.GenericServlet
public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
doPost
in class javax.servlet.http.HttpServlet
request
- the servlet request objectresponse
- the servlet response object
javax.servlet.ServletException
- if a servlet exception occurs
java.io.IOException
- if an I/O exception occurspublic void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
doGet
in class javax.servlet.http.HttpServlet
request
- the servlet request objectresponse
- the servlet response object
javax.servlet.ServletException
- if a servlet exception occurs
java.io.IOException
- if an I/O exception occurs
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |