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
 class VaadinServlet.RequestError
           
protected static class VaadinServlet.RequestType
          Deprecated. might be refactored or removed before 7.0.0
static class VaadinServlet.ServletService
           
 
Field Summary
 
Fields inherited from interface com.vaadin.server.Constants
DEFAULT_BUFFER_SIZE, DEFAULT_THEME_CACHETIME, DEFAULT_THEME_NAME, DEFAULT_WIDGETSET, ERROR_NO_UI_FOUND, 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, SERVLET_PARAMETER_CLOSE_IDLE_UIS, SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION, SERVLET_PARAMETER_HEARTBEAT_RATE, SERVLET_PARAMETER_PRODUCTION_MODE, SERVLET_PARAMETER_RESOURCE_CACHE_TIME, THEME_DIRECTORY_PATH, URL_PARAMETER_CLOSE_APPLICATION, URL_PARAMETER_REPAINT_ALL, URL_PARAMETER_RESTART_APPLICATION, URL_PARAMETER_THEME, WARNING_HEARTBEAT_INTERVAL_NOT_NUMERIC, WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC, WARNING_XSRF_PROTECTION_DISABLED, WIDGETSET_DIRECTORY_PATH, WIDGETSET_MISMATCH_INFO
 
Constructor Summary
VaadinServlet()
           
 
Method Summary
 CommunicationManager createCommunicationManager(VaadinSession application)
          Deprecated. Instead of overriding this method, override VaadinServletSession implementation via getApplicationContext(HttpSession) method and in that customized implementation return your CommunicationManager in VaadinServletSession#getApplicationManager(VaadinSession, VaadinServlet) method.
protected  DeploymentConfiguration createDeploymentConfiguration(java.util.Properties initParameters)
           
protected  VaadinServlet.ServletService createServletService(DeploymentConfiguration deploymentConfiguration)
           
protected  WrappedHttpServletRequest createWrappedRequest(javax.servlet.http.HttpServletRequest request)
          Create a wrapped request for a http servlet request.
protected  void criticalNotification(WrappedHttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String caption, java.lang.String message, java.lang.String details, java.lang.String url)
          Deprecated. might be refactored or removed before 7.0.0
 void destroy()
           
protected  VaadinSession getApplicationContext(javax.servlet.http.HttpSession session)
          Deprecated. might be refactored or removed before 7.0.0
protected  java.net.URL getApplicationUrl(javax.servlet.http.HttpServletRequest request)
          Deprecated. might be refactored or removed before 7.0.0
static java.lang.String getDefaultTheme()
          Returns the default theme.
protected  VaadinSession getExistingApplication(javax.servlet.http.HttpServletRequest request, boolean allowSessionCreation)
          Deprecated. might be refactored or removed before 7.0.0
protected  java.lang.String getRequestPathInfo(javax.servlet.http.HttpServletRequest request)
          Deprecated. might be refactored or removed before 7.0.0
protected  VaadinServlet.RequestType getRequestType(WrappedHttpServletRequest request)
          Deprecated. might be refactored or removed before 7.0.0
 java.lang.String getResourceLocation(java.lang.String theme, ThemeResource resource)
          Deprecated. might be refactored or removed before 7.0.0
protected static java.lang.String getResourcePath(javax.servlet.ServletContext servletContext, java.lang.String path)
          Deprecated. might be refactored or removed before 7.0.0
protected  VaadinServlet.ServletService getVaadinService()
          Gets a the vaadin service for this servlet.
 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. might be refactored or removed before 7.0.0
protected  void onVaadinSessionStarted(WrappedHttpServletRequest request, VaadinServletSession session)
           
static java.lang.String safeEscapeForHtml(java.lang.String unsafe)
          Deprecated. might be refactored or removed before 7.0.0
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 static java.lang.String stripSpecialChars(java.lang.String themeName)
          Deprecated. might be refactored or removed before 7.0.0
 
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.

createDeploymentConfiguration

protected DeploymentConfiguration createDeploymentConfiguration(java.util.Properties initParameters)

createServletService

protected VaadinServlet.ServletService createServletService(DeploymentConfiguration deploymentConfiguration)

destroy

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

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.

createWrappedRequest

protected WrappedHttpServletRequest createWrappedRequest(javax.servlet.http.HttpServletRequest request)
Create a wrapped request for a http servlet request. This method can be overridden if the wrapped request should have special properties.

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

getVaadinService

protected VaadinServlet.ServletService getVaadinService()
Gets a the vaadin service for this servlet.

Returns:
the vaadin service

criticalNotification

@Deprecated
protected void criticalNotification(WrappedHttpServletRequest request,
                                               javax.servlet.http.HttpServletResponse response,
                                               java.lang.String caption,
                                               java.lang.String message,
                                               java.lang.String details,
                                               java.lang.String url)
                             throws java.io.IOException
Deprecated. might be refactored or removed before 7.0.0

Send a notification to client's application. Used to notify client of critical errors, session expiration and more. Server has no knowledge of what application 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.

onVaadinSessionStarted

protected void onVaadinSessionStarted(WrappedHttpServletRequest request,
                                      VaadinServletSession session)
                               throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException

getResourcePath

@Deprecated
protected static java.lang.String getResourcePath(javax.servlet.ServletContext servletContext,
                                                             java.lang.String path)
Deprecated. might be refactored or removed before 7.0.0

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. might be refactored or removed before 7.0.0

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:

isAllowedVAADINResourceUrl

@Deprecated
protected boolean isAllowedVAADINResourceUrl(javax.servlet.http.HttpServletRequest request,
                                                        java.net.URL resourceUrl)
Deprecated. might be refactored or removed before 7.0.0

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(WrappedHttpServletRequest request)
Deprecated. might be refactored or removed before 7.0.0

Parameters:
request -
Returns:

getApplicationUrl

@Deprecated
protected java.net.URL getApplicationUrl(javax.servlet.http.HttpServletRequest request)
                                  throws java.net.MalformedURLException
Deprecated. might be refactored or removed before 7.0.0

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.

getExistingApplication

@Deprecated
protected VaadinSession getExistingApplication(javax.servlet.http.HttpServletRequest request,
                                                          boolean allowSessionCreation)
                                        throws java.net.MalformedURLException,
                                               SessionExpiredException
Deprecated. might be refactored or removed before 7.0.0

Gets the existing application for given request. Looks for application instance for given request based on the requested URL.

Parameters:
request - the HTTP request.
allowSessionCreation - true if a session should be created if no session exists, false if no session should be created
Returns:
Application instance, or null if the URL does not map to valid application.
Throws:
java.net.MalformedURLException - if the application is denied access to the persistent data store represented by the given URL.
java.lang.IllegalAccessException
java.lang.InstantiationException
SessionExpiredException

getRequestPathInfo

@Deprecated
protected java.lang.String getRequestPathInfo(javax.servlet.http.HttpServletRequest request)
Deprecated. might be refactored or removed before 7.0.0

Returns the path info; note that this _can_ be different than request.getPathInfo(). Examples where this might be useful:

getResourceLocation

@Deprecated
public java.lang.String getResourceLocation(java.lang.String theme,
                                                       ThemeResource resource)
Deprecated. might be refactored or removed before 7.0.0

Gets relative location of a theme resource.

Parameters:
theme - the Theme name.
resource - the Theme resource.
Returns:
External URI specifying the resource

getApplicationContext

@Deprecated
protected VaadinSession getApplicationContext(javax.servlet.http.HttpSession session)
Deprecated. might be refactored or removed before 7.0.0

Parameters:
session -
Returns:

createCommunicationManager

@Deprecated
public CommunicationManager createCommunicationManager(VaadinSession application)
Deprecated. Instead of overriding this method, override VaadinServletSession implementation via getApplicationContext(HttpSession) method and in that customized implementation return your CommunicationManager in VaadinServletSession#getApplicationManager(VaadinSession, VaadinServlet) method.

Override this method if you need to use a specialized communicaiton mananger implementation.

Parameters:
application -
Returns:

safeEscapeForHtml

@Deprecated
public static final java.lang.String safeEscapeForHtml(java.lang.String unsafe)
Deprecated. might be refactored or removed before 7.0.0

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-2011 Vaadin Ltd. All Rights Reserved.