Package org.openxava.web.servlets
Class Servlets
- java.lang.Object
-
- org.openxava.web.servlets.Servlets
-
public class Servlets extends java.lang.Object
Utilities to work with servlets.- Author:
- Javier Paniza
-
-
Constructor Summary
Constructors Constructor Description Servlets()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getCookie(javax.servlet.http.HttpServletRequest request, java.lang.String name)
static java.io.InputStream
getURIAsStream(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String uri)
From a uri return the resource (dynamic or static) in InputStream format.static java.io.InputStream
getURIAsStream(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String uri, java.lang.String encoding)
From a uri return the resource (dynamic or static) in InputStream format.static java.lang.String
getURIAsString(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String uri)
From a uri return the resource (dynamic or static) in String format.static void
setCharacterEncoding(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Try to set the system encoding as encoding for the request and response.
-
-
-
Method Detail
-
setCharacterEncoding
public static void setCharacterEncoding(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Try to set the system encoding as encoding for the request and response.The system encoding is obtained from
XSystem.getEncoding()
.
If fails a log messages is produced, but no exception is thrown.
-
getCookie
public static java.lang.String getCookie(javax.servlet.http.HttpServletRequest request, java.lang.String name)
-
getURIAsStream
public static java.io.InputStream getURIAsStream(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String uri) throws javax.servlet.ServletException, java.io.IOException
From a uri return the resource (dynamic or static) in InputStream format.Suitable for binary streams.
- Parameters:
request
- request of the current servletresponse
- response of the current servlet. This method does not write to ituri
- And uri, for example /mypage.jsp- Returns:
- The stream with the content of the resource in uri.
- Throws:
java.io.IOException
javax.servlet.ServletException
-
getURIAsStream
public static java.io.InputStream getURIAsStream(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String uri, java.lang.String encoding) throws javax.servlet.ServletException, java.io.IOException
From a uri return the resource (dynamic or static) in InputStream format.Suitable for characters streams.
- Parameters:
request
- request of the current servletresponse
- response of the current servlet. This method does not write to ituri
- And uri, for example /mypage.jspencoding
- Character encoding for the response- Returns:
- The stream with the content of the resource in uri
- Throws:
java.io.IOException
javax.servlet.ServletException
-
getURIAsString
public static java.lang.String getURIAsString(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String uri) throws javax.servlet.ServletException, java.io.IOException
From a uri return the resource (dynamic or static) in String format.- Parameters:
request
- request of the current servletresponse
- response of the current servlet. This method does not write to ituri
- And uri, for example /mypage.jsp- Returns:
- The string with the content of the resource in uri
- Throws:
java.io.IOException
javax.servlet.ServletException
-
-