com.vaadin.server
Class VaadinServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.vaadin.server.VaadinServlet
All Implemented Interfaces:
Constants, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
GAEVaadinServlet, LegacyVaadinServlet

public class VaadinServlet
extends javax.servlet.http.HttpServlet
implements Constants

See Also:
Serialized Form

Nested Class Summary
protected static class VaadinServlet.RequestType
          Deprecated. As of 7.0. This is no longer used and only provided for backwards compatibility. Each RequestHandler can individually decide whether it wants to handle a request or not.
 
Field Summary
 
Fields inherited from interface com.vaadin.server.Constants
ATMOSPHERE_MISSING_ERROR, DEFAULT_BUFFER_SIZE, DEFAULT_THEME_CACHETIME, DEFAULT_THEME_NAME, DEFAULT_WIDGETSET, ERROR_NO_UI_FOUND, INVALID_ATMOSPHERE_VERSION_WARNING, INVALID_SECURITY_KEY_MSG, MAX_BUFFER_SIZE, NOT_PRODUCTION_MODE_INFO, PARAMETER_VAADIN_RESOURCES, PARAMETER_WIDGETSET, PORTAL_PARAMETER_VAADIN_RESOURCE_PATH, PORTAL_PARAMETER_VAADIN_THEME, PORTAL_PARAMETER_VAADIN_WIDGETSET, PUSH_NOT_SUPPORTED_ERROR, REQUIRED_ATMOSPHERE_RUNTIME_VERSION, SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS, SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION, SERVLET_PARAMETER_HEARTBEAT_INTERVAL, SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING, SERVLET_PARAMETER_PRODUCTION_MODE, SERVLET_PARAMETER_PUSH_MODE, SERVLET_PARAMETER_RESOURCE_CACHE_TIME, SERVLET_PARAMETER_UI_PROVIDER, THEME_DIR_PATH, URL_PARAMETER_THEME, WARNING_HEARTBEAT_INTERVAL_NOT_NUMERIC, WARNING_LEGACY_PROPERTY_TOSTRING, WARNING_PUSH_MODE_NOT_RECOGNIZED, WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC, WARNING_UNKNOWN_LEGACY_PROPERTY_TOSTRING_VALUE, WARNING_XSRF_PROTECTION_DISABLED, WIDGETSET_DIR_PATH, WIDGETSET_MISMATCH_INFO
 
Constructor Summary
VaadinServlet()
           
 
Method Summary
protected  DeploymentConfiguration createDeploymentConfiguration(java.util.Properties initParameters)
           
protected  VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration)
           
protected  VaadinServletRequest createVaadinRequest(javax.servlet.http.HttpServletRequest request)
          Create a Vaadin request for a http servlet request.
protected  void criticalNotification(VaadinServletRequest request, VaadinServletResponse response, java.lang.String caption, java.lang.String message, java.lang.String details, java.lang.String url)
          Deprecated. As of 7.0. This method is retained only for backwards compatibility and for GAEVaadinServlet.
 void destroy()
           
protected  java.net.URL getApplicationUrl(javax.servlet.http.HttpServletRequest request)
          Deprecated. As of 7.0. Will likely change or be removed in a future version
static VaadinServlet getCurrent()
          Gets the currently used Vaadin servlet.
static java.lang.String getDefaultTheme()
          Returns the default theme.
protected  VaadinServlet.RequestType getRequestType(VaadinServletRequest request)
          Deprecated. As of 7.0. This is no longer used and only provided for backwards compatibility. Each RequestHandler can individually decide whether it wants to handle a request or not.
protected static java.lang.String getResourcePath(javax.servlet.ServletContext servletContext, java.lang.String path)
          Deprecated. As of 7.0. Will likely change or be removed in a future version
protected  VaadinServletService getService()
          Gets a the vaadin service for this servlet.
protected  boolean handleContextRootWithoutSlash(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Invoked for every request to this servlet to potentially send a redirect to avoid problems with requests to the context root with no trailing slash.
 void init(javax.servlet.ServletConfig servletConfig)
          Called by the servlet container to indicate to a servlet that the servlet is being placed into service.
protected  boolean isAllowedVAADINResourceUrl(javax.servlet.http.HttpServletRequest request, java.net.URL resourceUrl)
          Deprecated. As of 7.0. Will likely change or be removed in a future version
protected  boolean isStaticResourceRequest(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String safeEscapeForHtml(java.lang.String unsafe)
          Deprecated. As of 7.0. Will likely change or be removed in a future version
protected  void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Receives standard HTTP requests from the public service method and dispatches them.
protected  void servletInitialized()
           
protected static java.lang.String stripSpecialChars(java.lang.String themeName)
          Deprecated. As of 7.0. Will likely change or be removed in a future version
protected  void writeStaticResourceResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.net.URL resourceUrl)
          Writes the contents of the given resourceUrl in the response.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VaadinServlet

public VaadinServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig servletConfig)
          throws javax.servlet.ServletException
Called by the servlet container to indicate to a servlet that the servlet is being placed into service.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
servletConfig - the object containing the servlet's configuration and initialization parameters
Throws:
javax.servlet.ServletException - if an exception has occurred that interferes with the servlet's normal operation.

servletInitialized

protected void servletInitialized()
                           throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException

getCurrent

public static VaadinServlet getCurrent()
Gets the currently used Vaadin servlet. The current servlet is automatically defined when initializing the servlet and when processing requests to the server and in threads started at a point when the current servlet is defined (see InheritableThreadLocal). In other cases, (e.g. from background threads started in some other way), the current servlet is not automatically defined.

The current servlet is derived from the current service using VaadinService.getCurrent()

Returns:
the current Vaadin servlet instance if available, otherwise null
Since:
7.0

createDeploymentConfiguration

protected DeploymentConfiguration createDeploymentConfiguration(java.util.Properties initParameters)

createServletService

protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration)
                                             throws ServiceException
Throws:
ServiceException

service

protected void service(javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response)
                throws javax.servlet.ServletException,
                       java.io.IOException
Receives standard HTTP requests from the public service method and dispatches them.

Overrides:
service in class javax.servlet.http.HttpServlet
Parameters:
request - the object that contains the request the client made of the servlet.
response - the object that contains the response the servlet returns to the client.
Throws:
javax.servlet.ServletException - if an input or output error occurs while the servlet is handling the TRACE request.
java.io.IOException - if the request for the TRACE cannot be handled.

handleContextRootWithoutSlash

protected boolean handleContextRootWithoutSlash(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response)
                                         throws java.io.IOException
Invoked for every request to this servlet to potentially send a redirect to avoid problems with requests to the context root with no trailing slash.

Parameters:
request - the processed request
response - the processed response
Returns:
true if a redirect has been sent and the request should not be processed further; false if the request should be processed as usual
Throws:
java.io.IOException - If an input or output exception occurs

createVaadinRequest

protected VaadinServletRequest createVaadinRequest(javax.servlet.http.HttpServletRequest request)
Create a Vaadin request for a http servlet request. This method can be overridden if the Vaadin request should have special properties.

Parameters:
request - the original http servlet request
Returns:
a Vaadin request for the original request

getService

protected VaadinServletService getService()
Gets a the vaadin service for this servlet.

Returns:
the vaadin service

criticalNotification

@Deprecated
protected void criticalNotification(VaadinServletRequest request,
                                               VaadinServletResponse response,
                                               java.lang.String caption,
                                               java.lang.String message,
                                               java.lang.String details,
                                               java.lang.String url)
                             throws java.io.IOException
Deprecated. As of 7.0. This method is retained only for backwards compatibility and for GAEVaadinServlet.

Send a notification to client-side widgetset. Used to notify client of critical errors, session expiration and more. Server has no knowledge of what UI client refers to.

Parameters:
request - the HTTP request instance.
response - the HTTP response to write to.
caption - the notification caption
message - to notification body
details - a detail message to show in addition to the message. Currently shown directly below the message but could be hidden behind a details drop down in the future. Mainly used to give additional information not necessarily useful to the end user.
url - url to load when the message is dismissed. Null will reload the current page.
Throws:
java.io.IOException - if the writing failed due to input/output error.

getResourcePath

@Deprecated
protected static java.lang.String getResourcePath(javax.servlet.ServletContext servletContext,
                                                             java.lang.String path)
Deprecated. As of 7.0. Will likely change or be removed in a future version

Gets resource path using different implementations. Required to supporting different servlet container implementations (application servers).

Parameters:
servletContext -
path - the resource path.
Returns:
the resource path.

stripSpecialChars

@Deprecated
protected static java.lang.String stripSpecialChars(java.lang.String themeName)
Deprecated. As of 7.0. Will likely change or be removed in a future version

A helper method to strip away characters that might somehow be used for XSS attacs. Leaves at least alphanumeric characters intact. Also removes eg. ( and ), so values should be safe in javascript too.

Parameters:
themeName -
Returns:

getDefaultTheme

public static java.lang.String getDefaultTheme()
Returns the default theme. Must never return null.

Returns:

writeStaticResourceResponse

protected void writeStaticResourceResponse(javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response,
                                           java.net.URL resourceUrl)
                                    throws java.io.IOException
Writes the contents of the given resourceUrl in the response. Can be overridden to add/modify response headers and similar.

Parameters:
request - The request for the resource
response - The response
resourceUrl - The url to send
Throws:
java.io.IOException

isAllowedVAADINResourceUrl

@Deprecated
protected boolean isAllowedVAADINResourceUrl(javax.servlet.http.HttpServletRequest request,
                                                        java.net.URL resourceUrl)
Deprecated. As of 7.0. Will likely change or be removed in a future version

Check whether a URL obtained from a classloader refers to a valid static resource in the directory VAADIN. Warning: Overriding of this method is not recommended, but is possible to support non-default classloaders or servers that may produce URLs different from the normal ones. The method prototype may change in the future. Care should be taken not to expose class files or other resources outside the VAADIN directory if the method is overridden.

Parameters:
request -
resourceUrl -
Returns:
Since:
6.6.7

getRequestType

@Deprecated
protected VaadinServlet.RequestType getRequestType(VaadinServletRequest request)
Deprecated. As of 7.0. This is no longer used and only provided for backwards compatibility. Each RequestHandler can individually decide whether it wants to handle a request or not.

Parameters:
request -
Returns:

isStaticResourceRequest

protected boolean isStaticResourceRequest(javax.servlet.http.HttpServletRequest request)

getApplicationUrl

@Deprecated
protected java.net.URL getApplicationUrl(javax.servlet.http.HttpServletRequest request)
                                  throws java.net.MalformedURLException
Deprecated. As of 7.0. Will likely change or be removed in a future version

Gets the current application URL from request.

Parameters:
request - the HTTP request.
Throws:
java.net.MalformedURLException - if the application is denied access to the persistent data store represented by the given URL.

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

safeEscapeForHtml

@Deprecated
public static final java.lang.String safeEscapeForHtml(java.lang.String unsafe)
Deprecated. As of 7.0. Will likely change or be removed in a future version

Escapes characters to html entities. An exception is made for some "safe characters" to keep the text somewhat readable.

Parameters:
unsafe -
Returns:
a safe string to be added inside an html tag


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.