org.openxava.web.servlets
Class Servlets

java.lang.Object
  extended by org.openxava.web.servlets.Servlets

public class Servlets
extends java.lang.Object

Utilities to work with servlets.

Author:
Javier Paniza

Constructor Summary
Servlets()
           
 
Method Summary
static java.io.InputStream getURIAsStream(HttpServletRequest request, HttpServletResponse response, java.lang.String uri)
          From a uri return the resource (dynamic or static) in InputStream format.
static java.io.InputStream getURIAsStream(HttpServletRequest request, 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(HttpServletRequest request, HttpServletResponse response, java.lang.String uri)
          From a uri return the resource (dynamic or static) in String format.
static void setCharacterEncoding(HttpServletRequest request, HttpServletResponse response)
          Try to set the system encoding as encoding for the request and response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Servlets

public Servlets()
Method Detail

setCharacterEncoding

public static void setCharacterEncoding(HttpServletRequest request,
                                        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.


getURIAsStream

public static java.io.InputStream getURIAsStream(HttpServletRequest request,
                                                 HttpServletResponse response,
                                                 java.lang.String uri)
                                          throws 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 servlet
response - response of the current servlet. This method does not write to it
uri - And uri, for example /mypage.jsp
Returns:
The stream with the content of the resource in uri.
Throws:
java.io.IOException
ServletException

getURIAsStream

public static java.io.InputStream getURIAsStream(HttpServletRequest request,
                                                 HttpServletResponse response,
                                                 java.lang.String uri,
                                                 java.lang.String encoding)
                                          throws 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 servlet
response - response of the current servlet. This method does not write to it
uri - And uri, for example /mypage.jsp
encoding - Character encoding for the response
Returns:
The stream with the content of the resource in uri
Throws:
java.io.IOException
ServletException

getURIAsString

public static java.lang.String getURIAsString(HttpServletRequest request,
                                              HttpServletResponse response,
                                              java.lang.String uri)
                                       throws ServletException,
                                              java.io.IOException
From a uri return the resource (dynamic or static) in String format.

Parameters:
request - request of the current servlet
response - response of the current servlet. This method does not write to it
uri - And uri, for example /mypage.jsp
Returns:
The string with the content of the resource in uri
Throws:
java.io.IOException
ServletException