Interface Request

  • All Known Implementing Classes:
    AbstractRequest, MockRequest, ServletRequest

    public interface Request
    The interface that the Web framework needs to see from the HttpServletRequest. The support for "session scope" variables should not be used except for communicating between separate WComponent trees (e.g. in separate servlets).

    The WServlet class is the generic servlet that sits between the servlet container and the WComponent framework. The WServlet class is responsible for creating Request objects that represent the incoming HTTP requests, and for dispatching them to the WComponent tree.

    Since:
    1.0.0
    Author:
    James Gifford
    See Also:
    WServlet
    • Method Detail

      • getParameter

        String getParameter​(String key)
        Returns the value of a request parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.

        You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use getParameterValues(java.lang.String).

        If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by getParameterValues.

        Parameters:
        key - a String specifying the key/name of the parameter
        Returns:
        a String representing the single value of the parameter
        See Also:
        getParameterValues(java.lang.String)
      • getParameterValues

        String[] getParameterValues​(String key)
        Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.

        If the parameter has a single value, the array has a length of 1.

        Parameters:
        key - a String containing the key/name of the parameter whose value is requested
        Returns:
        an array of String objects containing the parameter's values
        See Also:
        getParameter(java.lang.String)
      • getFileContents

        byte[] getFileContents​(String key)
        If the request parameter is a file attachment, use this method to access the content of the attached file.
        Parameters:
        key - the name of the parameter used to pass the file content.
        Returns:
        the binary data for the uploaded file.
      • getFileItem

        org.apache.commons.fileupload.FileItem getFileItem​(String key)
        Deprecated.
        As of 25/05/2015, replaced by getFileItems(java.lang.String)
        If the request parameter is a file attachment, use this method to access the parsed FileItem.
        Parameters:
        key - the name of the parameter used to pass the file content.
        Returns:
        FileItem representing the uploaded file.
        Since:
        1.0.0
      • getFileItems

        org.apache.commons.fileupload.FileItem[] getFileItems​(String key)
        If the request parameter is a file attachment, use this method to access the parsed FileItem[].
        Parameters:
        key - the name of the parameter used to pass the file content.
        Returns:
        FileItem[] representing the uploaded files.
        Since:
        1.0.0
      • getParameterNames

        Enumeration getParameterNames()
        Returns:
        an Enumeration of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an empty Enumeration.
      • getParameters

        Map<String,​String[]> getParameters()
        Returns:
        the complete list of parameters contained in this request. If the request contains no parameters, the method returns an empty Map.
      • getFiles

        Map<String,​org.apache.commons.fileupload.FileItem[]> getFiles()
        Retrieves the files which were uploaded in this request.
        Returns:
        the uploaded files.
      • containsSameData

        boolean containsSameData​(Request other)
        Indicates whether the given request contains the same set of parameters as this one.
        Parameters:
        other - the request to check.
        Returns:
        true if the other request contains the same parameters as this one.
      • getAttribute

        Serializable getAttribute​(String key)

        Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

        Attributes can be set two ways. The container may set attributes to make available custom information about a request. Attributes can also be set programatically using setAttribute.

        Parameters:
        key - the request attribute key
        Returns:
        an Object containing the value of the attribute, or null if the attribute does not exist
      • setAttribute

        void setAttribute​(String key,
                          Serializable value)
        Stores an attribute in this request. Attributes are reset between requests. If the object passed in is null, the effect is the same as removing the attribute.
        Parameters:
        key - the attribute key
        value - the attribute value
      • getSessionAttribute

        Serializable getSessionAttribute​(String key)
        Returns the object bound with the specified name in this session, or null if no object is bound under the name.
        Parameters:
        key - the session attribute key
        Returns:
        an Object containing the value of the attribute, or null if the attribute does not exist
      • getAppSessionAttribute

        @Deprecated
        Serializable getAppSessionAttribute​(String key)
        Deprecated.
        portlet specific
        Returns the object bound with the specified name in the application session, or null if no object is bound under the name.

        This method is relevant for portlets in which case getAppSessionAttribute accesses a portlet scoped session, while getSessionAttribute accesses the global session.

        Parameters:
        key - the session attribute key
        Returns:
        an Object containing the value of the attribute, or null if the attribute does not exist
      • setSessionAttribute

        void setSessionAttribute​(String key,
                                 Serializable value)
        Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.

        If the value passed in is null, this has the same effect as removing the attribute.

        Parameters:
        key - the session attribute key.
        value - an Object containing the value of the attribute.
      • setAppSessionAttribute

        @Deprecated
        void setAppSessionAttribute​(String key,
                                    Serializable value)
        Deprecated.
        portlet specific
        Binds an object to the application session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.

        If the value passed in is null, this has the same effect as removing the attribute.

        This method is relevant for portlets in which case getAppSessionAttribute accesses a portlet scoped session, while getSessionAttribute accesses the global session.

        Parameters:
        key - the session attribute key.
        value - an Object containing the value of the attribute.
      • getAppPreferenceParameter

        String getAppPreferenceParameter​(String key)
        Gets the parameter for the given key. If no such parameter is defined, returns null. This method differs from Parameters.getInstance().get(key) in that the value returned may be customised to suit the "app". In a portlet environment an "app" is represented by a portlet.
        Parameters:
        key - the preference parameter key.
        Returns:
        the app preference parameter, or null if not found.
      • logout

        void logout()
        Signal to the servlet that we want to log out (terminate the session). The container should react by invalidating the session and redirecting the client to some suitable page.
        See Also:
        AbstractContainerHelper.redirectForLogout()
      • isLogout

        boolean isLogout()
        Returns:
        true if logout() has been called
      • setEvent

        void setEvent​(String action,
                      String parameter,
                      Serializable value)
        Deprecated.
        portal specific
        Triggers the publishing event using the value as the event payload.
        Parameters:
        action - name of the publishing event to trigger
        parameter - the key for the event payload value
        value - the value of the event payload
        Since:
        1.0.0
      • setEvent

        void setEvent​(String action,
                      HashMap<String,​Serializable> eventMap)
        Deprecated.
        portal specific
        Triggers the publishing event using the eventMap as the event payload.
        Parameters:
        action - name of the publishing event to trigger
        eventMap - the key/value pair for the event payload
        Since:
        1.0.0
      • setRenderParameter

        void setRenderParameter​(String key,
                                Serializable value)
        Deprecated.
        Support for Public Render Parameters in Portal. In a Servlet environment, this will be the same as the session.
        Parameters:
        key - The key for the parameter.
        value - The value of the parameter.
        Since:
        1.0.0
      • getRenderParameter

        Serializable getRenderParameter​(String key)
        Deprecated.
        portal specific. user getSessionAttribute(String)
        Support for Public Render Parameters in Portal. In a Servlet environment, this will be the same as the session.
        Parameters:
        key - The key for the parameter.
        Returns:
        The value of the parameter.
        Since:
        1.0.0
      • isUserInRole

        boolean isUserInRole​(String role)
        Returns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returns false.
        Parameters:
        role - a String specifying the name of the role.
        Returns:
        a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated.
        Since:
        1.0.0
      • getMethod

        String getMethod()
        Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. Same as the value of the CGI variable REQUEST_METHOD.
        Returns:
        a String specifying the name of the method with which this request was made
      • getMaxInactiveInterval

        int getMaxInactiveInterval()
        Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses.
        Returns:
        an int specifying the maximum inactive interval in seconds. Negative if the session never expires.