Package org.apache.struts2.result
Class PlainTextResult
java.lang.Object
org.apache.struts2.result.StrutsResultSupport
org.apache.struts2.result.PlainTextResult
- All Implemented Interfaces:
Serializable
,Result
,StrutsStatics
A result that send the content out as plain text. Useful typically when needed
to display the raw content of a JSP or Html file for example.
- location (default) = location of the file (jsp/html) to be displayed as plain text.
- charSet (optional) = character set to be used. This character set will be used to set the response type (eg. Content-Type=text/plain; charset=UTF-8) and when reading using a Reader. Some example of charSet would be UTF-8, ISO-8859-1 etc.
<action name="displayJspRawContent" > <result type="plainText">/myJspFile.jsp</result> </action> <action name="displayJspRawContent" > <result type="plainText"> <param name="location">/myJspFile.jsp</param> <param name="charSet">UTF-8</param> </result> </action>
- See Also:
-
Field Summary
FieldsFields inherited from class org.apache.struts2.result.StrutsResultSupport
DEFAULT_PARAM, DEFAULT_URL_ENCODING, parseLocation
Fields inherited from interface org.apache.struts2.StrutsStatics
ACTION_MAPPING, HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_ACTION_TAG_INVOCATION
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
adjustLocation
(String location) protected void
applyAdditionalHeaders
(jakarta.servlet.http.HttpServletResponse response) protected void
applyCharset
(Charset charset, jakarta.servlet.http.HttpServletResponse response) protected void
doExecute
(String finalLocation, ActionInvocation invocation) Executes the result given a final location (jsp page, action, etc) and the action invocation (the state in which the action was executed).Set the character setprotected void
logWrongStream
(String finalLocation, InputStream resourceAsStream) protected Charset
protected InputStream
readStream
(ActionInvocation invocation, String location) protected void
sendStream
(PrintWriter writer, InputStreamReader reader) void
setCharSet
(String charSet) Set the character setMethods inherited from class org.apache.struts2.result.StrutsResultSupport
conditionalParse, conditionalParseCollection, execute, getLastFinalLocation, getLocation, setEncode, setLocation, setParse
-
Field Details
-
BUFFER_SIZE
public static final int BUFFER_SIZE- See Also:
-
-
Constructor Details
-
PlainTextResult
public PlainTextResult() -
PlainTextResult
-
-
Method Details
-
getCharSet
Set the character set- Returns:
- The character set
-
setCharSet
Set the character set- Parameters:
charSet
- The character set
-
doExecute
Description copied from class:StrutsResultSupport
Executes the result given a final location (jsp page, action, etc) and the action invocation (the state in which the action was executed). Subclasses must implement this class to handle custom logic for result handling.- Specified by:
doExecute
in classStrutsResultSupport
- Parameters:
finalLocation
- the location (jsp page, action, etc) to go to.invocation
- the execution state of the action.- Throws:
Exception
- if an error occurs while executing the result.
-
readStream
-
logWrongStream
-
sendStream
- Throws:
IOException
-
adjustLocation
-
applyAdditionalHeaders
protected void applyAdditionalHeaders(jakarta.servlet.http.HttpServletResponse response) -
applyCharset
-
readCharset
-