Class Servlets

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

public class Servlets extends Object
Utilities to work with servlets.

Author:
Javier Paniza
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getCookie(javax.servlet.http.HttpServletRequest request, String name)
     
    getURIAsStream(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String uri)
    From a uri return the resource (dynamic or static) in InputStream format.
    getURIAsStream(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String uri, String encoding)
    From a uri return the resource (dynamic or static) in InputStream format.
    static String
    getURIAsString(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Servlets

      public Servlets()
  • Method Details

    • 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 String getCookie(javax.servlet.http.HttpServletRequest request, String name)
    • getURIAsStream

      public static InputStream getURIAsStream(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String uri) throws javax.servlet.ServletException, 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:
      IOException
      javax.servlet.ServletException
    • getURIAsStream

      public static InputStream getURIAsStream(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String uri, String encoding) throws javax.servlet.ServletException, 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:
      IOException
      javax.servlet.ServletException
    • getURIAsString

      public static String getURIAsString(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String uri) throws javax.servlet.ServletException, 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:
      IOException
      javax.servlet.ServletException