com.vaadin.server.

Interface VaadinRequest

    • Method Summary

      All Methods
      Modifier and Type Method and Description
      Object getAttribute(String name)

      Gets a request attribute.

      Enumeration<String> getAttributeNames()

      Returns an Enumeration containing the names of the attributes available to this request.

      String getAuthType()

      Returns the name of the authentication scheme used for the connection between client and server, for example, BASIC_AUTH, CLIENT_CERT_AUTH, a custom one or null if there was no authentication.

      String getCharacterEncoding()

      Returns the name of the character encoding used in the body of this request.

      int getContentLength()

      Returns the length of the request content that can be read from the input stream returned by getInputStream().

      String getContentType()

      Returns the MIME type of the body of the request, or null if the type is not known.

      String getContextPath()

      Returns the portion of the request URI that indicates the context of the request.

      Cookie[] getCookies()

      Returns an array containing all of the Cookie objects the client sent with this request.

      static VaadinRequest getCurrent()

      Gets the currently processed Vaadin request.

      long getDateHeader(String name)

      Returns the value of the specified request header as a long value that represents a Date object.

      String getHeader(String headerName)

      Gets the value of a request header, e.g.

      Enumeration<String> getHeaderNames()

      Returns an enumeration of all the header names this request contains.

      Enumeration<String> getHeaders(String name)

      Returns all the values of the specified request header as an Enumeration of String objects.

      InputStream getInputStream()

      Returns an input stream from which the request content can be read.

      Locale getLocale()

      Gets locale information from the query, e.g.

      Enumeration<Locale> getLocales()

      Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.

      String getMethod()

      Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.

      String getParameter(String parameter)

      Gets the named request parameter This is typically a HTTP GET or POST parameter, though other request types might have other ways of representing parameters.

      Map<String,String[]> getParameterMap()

      Gets all the parameters of the request.

      String getPathInfo()

      Gets the path of the requested resource relative to the application.

      BufferedReader getReader()

      Retrieves the body of the request as character data using a BufferedReader.

      String getRemoteAddr()

      Returns the IP address from which the request came.

      String getRemoteHost()

      Returns the fully qualified name of the client or the last proxy that sent the request.

      int getRemotePort()

      Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.

      String getRemoteUser()

      Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.

      VaadinService getService()

      Gets the vaadin service for the context of this request.

      Principal getUserPrincipal()

      Returns a java.security.Principal object containing the name of the current authenticated user.

      WrappedSession getWrappedSession()

      Gets the session associated with this request, creating a new if there is no session.

      WrappedSession getWrappedSession(boolean allowSessionCreation)

      Gets the session associated with this request, optionally creating a new if there is no session.

      boolean isSecure()

      Checks whether the request was made using a secure channel, e.g.

      boolean isUserInRole(String role)

      Returns a boolean indicating whether the authenticated user is included in the specified logical "role".

      void removeAttribute(String name)

      Removes an attribute from this request.

      void setAttribute(String name, Object value)

      Defines a request attribute.

    • Method Detail

      • getParameter

        String getParameter(String parameter)

        Gets the named request parameter This is typically a HTTP GET or POST parameter, though other request types might have other ways of representing parameters.

        Parameters:

        parameter - the name of the parameter

        Returns:

        The parameter value, or null if no parameter with the given name is present

        See Also:

        ServletRequest.getParameter(String), PortletRequest.getParameter(String)

      • getPathInfo

        String getPathInfo()

        Gets the path of the requested resource relative to the application. The path is null if no path information is available. Does always start with / if the path isn't null.

        Returns:

        a string with the path relative to the application.

        See Also:

        HttpServletRequest.getPathInfo()

      • getRemoteAddr

        String getRemoteAddr()

        Returns the IP address from which the request came. This might also be the address of a proxy between the server and the original requester.

        Returns:

        a string containing the IP address, or null if the address is not available

        See Also:

        ServletRequest.getRemoteAddr()

      • getService

        VaadinService getService()

        Gets the vaadin service for the context of this request.

        Returns:

        the vaadin service

        See Also:

        VaadinService

      • getCookies

        Cookie[] getCookies()

        Returns an array containing all of the Cookie objects the client sent with this request. This method returns null if no cookies were sent.

        Returns:

        an array of all the Cookies included with this request, or null if the request has no cookies

        See Also:

        HttpServletRequest.getCookies(), PortletRequest.getCookies()

      • getAuthType

        String getAuthType()

        Returns the name of the authentication scheme used for the connection between client and server, for example, BASIC_AUTH, CLIENT_CERT_AUTH, a custom one or null if there was no authentication.

        Returns:

        a string indicating the authentication scheme, or null if the request was not authenticated.

        See Also:

        HttpServletRequest.getAuthType(), PortletRequest.getAuthType()

      • getRemoteUser

        String getRemoteUser()

        Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication.

        Returns:

        a String specifying the login of the user making this request, or null if the user login is not known.

        See Also:

        HttpServletRequest.getRemoteUser(), PortletRequest.getRemoteUser()

      • getUserPrincipal

        Principal getUserPrincipal()

        Returns a java.security.Principal object containing the name of the current authenticated user. If the user has not been authenticated, the method returns null.

        Returns:

        a java.security.Principal containing the name of the user making this request; null if the user has not been authenticated

        See Also:

        HttpServletRequest.getUserPrincipal(), PortletRequest.getUserPrincipal()

      • 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

        See Also:

        HttpServletRequest.isUserInRole(String), PortletRequest.isUserInRole(String)

      • getLocales

        Enumeration<Locale> getLocales()

        Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns an Enumeration containing one Locale, the default locale for the server.

        Returns:

        an Enumeration of preferred Locale objects for the client

        See Also:

        ServletRequest.getLocales(), PortletRequest.getLocales()

      • getRemoteHost

        String getRemoteHost()

        Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address.

        Returns:

        a String containing the fully qualified name of the client, or null if the information is not available.

        See Also:

        ServletRequest.getRemoteHost()

      • getRemotePort

        int getRemotePort()

        Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.

        Returns:

        an integer specifying the port number, or -1 if the information is not available.

        See Also:

        ServletRequest.getRemotePort()

      • getCharacterEncoding

        String getCharacterEncoding()

        Returns the name of the character encoding used in the body of this request. This method returns null if the request does not specify a character encoding.

        Returns:

        a String containing the name of the character encoding, or null if the request does not specify a character encoding

        See Also:

        ServletRequest.getCharacterEncoding(), ClientDataRequest.getCharacterEncoding()

      • getDateHeader

        long getDateHeader(String name)

        Returns the value of the specified request header as a long value that represents a Date object. Use this method with headers that contain dates, such as If-Modified-Since.

        The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive.

        If the request did not have a header of the specified name, this method returns -1. If the header can't be converted to a date, the method throws an IllegalArgumentException.

        Parameters:

        name - a String specifying the name of the header

        Returns:

        a long value representing the date specified in the header expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the named header was not included with the request

        Throws:

        IllegalArgumentException - If the header value can't be converted to a date

        See Also:

        HttpServletRequest.getDateHeader(String)

      • getHeaderNames

        Enumeration<String> getHeaderNames()

        Returns an enumeration of all the header names this request contains. If the request has no headers, this method returns an empty enumeration.

        Some implementations do not allow access headers using this method, in which case this method returns null

        Returns:

        an enumeration of all the header names sent with this request; if the request has no headers, an empty enumeration; if the implementation does not allow this method, null

        See Also:

        HttpServletRequest.getHeaderNames()

      • getHeaders

        Enumeration<String> getHeaders(String name)

        Returns all the values of the specified request header as an Enumeration of String objects.

        Some headers, such as Accept-Language can be sent by clients as several headers each with a different value rather than sending the header as a comma separated list.

        If the request did not include any headers of the specified name, this method returns an empty Enumeration. If the request does not support accessing headers, this method returns null.

        The header name is case insensitive. You can use this method with any request header.

        Parameters:

        name - a String specifying the header name

        Returns:

        an Enumeration containing the values of the requested header. If the request does not have any headers of that name return an empty enumeration. If the header information is not available, return null

        See Also:

        HttpServletRequest.getHeaders(String)

      • getCurrent

        static VaadinRequest getCurrent()

        Gets the currently processed Vaadin request. The current request is automatically defined when the request is started. The current request can not be used in e.g. background threads because of the way server implementations reuse request instances.

        Returns:

        the current Vaadin request instance if available, otherwise null

        Since:

        8.1