public class VaadinServlet
extends javax.servlet.http.HttpServlet
This servlet is typically subclassed in all applications to provide servlet mappings and init parameters. Together with a web.xml file, it is also possible to use this class directly.
Internally sets up a VaadinService
through
createServletService(DeploymentConfiguration)
and delegates handling
of most requests to that.
Constructor and Description |
---|
VaadinServlet() |
Modifier and Type | Method and Description |
---|---|
protected DeploymentConfiguration |
createDeploymentConfiguration()
Creates a deployment configuration to be used for the creation of a
VaadinService . |
protected DeploymentConfiguration |
createDeploymentConfiguration(Properties initParameters)
Creates a deployment configuration to be used for the creation of a
VaadinService . |
protected VaadinServletService |
createServletService()
Creates a vaadin servlet service.
|
protected VaadinServletService |
createServletService(DeploymentConfiguration deploymentConfiguration)
Creates a vaadin servlet service.
|
protected VaadinServletRequest |
createVaadinRequest(javax.servlet.http.HttpServletRequest request)
Creates a Vaadin request for a http servlet request.
|
void |
destroy() |
protected 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.
|
protected static String |
getLastPathParameter(String uri)
Finds any path parameter added to the last part of the uri.
|
VaadinServletService |
getService()
Gets the Vaadin service for this servlet.
|
protected Optional<WebJarServer> |
getWebJarServer()
Gets the web jar server.
|
protected boolean |
handleContextOrServletRootWithoutSlash(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.
|
static String |
safeEscapeForHtml(String unsafe)
Deprecated.
As of 7.0. Will likely change or be removed in a future
version
|
protected boolean |
serveStaticOrWebJarRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handles a request by serving a static file or a file from a WebJar.
|
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() |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
public void init(javax.servlet.ServletConfig servletConfig) throws javax.servlet.ServletException
init
in interface javax.servlet.Servlet
init
in class javax.servlet.GenericServlet
servletConfig
- the object containing the servlet's configuration and
initialization parametersjavax.servlet.ServletException
- if an exception has occurred that interferes with the
servlet's normal operation.protected void servletInitialized() throws javax.servlet.ServletException
javax.servlet.ServletException
public static VaadinServlet getCurrent()
ThreadLocal
) and in
VaadinSession.access(Command)
and UI.access(Command)
. In
other cases, (e.g. from background threads), the current servlet is not
automatically defined.
The current servlet is derived from the current service using
VaadinService.getCurrent()
null
protected DeploymentConfiguration createDeploymentConfiguration() throws javax.servlet.ServletException
VaadinService
. Intended to be used by dependency injection
frameworks.javax.servlet.ServletException
- if construction of the Properties
for
DeploymentConfigurationFactory.createInitParameters(Class, ServletConfig)
failsprotected DeploymentConfiguration createDeploymentConfiguration(Properties initParameters)
VaadinService
. Override this if you want to override certain
properties.initParameters
- the context-param and init-param values as propertiesprotected VaadinServletService createServletService() throws javax.servlet.ServletException, ServiceException
init(ServletConfig)
and
createServletService(DeploymentConfiguration)
so dependency
injection frameworks can call createDeploymentConfiguration()
when creating a vaadin servlet service lazily.javax.servlet.ServletException
- if creating a deployment configuration failsServiceException
- if creating the vaadin servlet service failsprotected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException
deploymentConfiguration
- the deployment configuration to be usedServiceException
- if creating the vaadin servlet service failsprotected void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
service
in class javax.servlet.http.HttpServlet
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.javax.servlet.ServletException
- if an input or output error occurs while the servlet is
handling the TRACE request.IOException
- if the request for the TRACE cannot be handled.protected boolean serveStaticOrWebJarRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
request
- the HTTP servlet request object that contains the request the
client made of the servletresponse
- the HTTP servlet response object that contains the response
the servlet returns to the clienttrue
if the request was handled a response written;
oterwise false
IOException
- if an input or output error occurs while the servlet is
handling the HTTP requestjavax.servlet.ServletException
- if the HTTP request cannot be handledprotected boolean handleContextOrServletRootWithoutSlash(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
request
- the processed requestresponse
- the processed responsetrue
if a redirect has been sent and the request
should not be processed further; false
if the
request should be processed as usualIOException
- If an input or output exception occursprotected static String getLastPathParameter(String uri)
For example the uri http://myhost.com/foo;a=1/bar;b=1 contains two path parameters, a=1 related to /foo and b=1 related to /bar.
For http://myhost.com/foo;a=1/bar;b=1 this method will return ;b=1
uri
- a URIprotected VaadinServletRequest createVaadinRequest(javax.servlet.http.HttpServletRequest request)
request
- the original http servlet requestpublic VaadinServletService getService()
@Deprecated protected URL getApplicationUrl(javax.servlet.http.HttpServletRequest request) throws MalformedURLException
request
- the HTTP request.MalformedURLException
- if the application is denied access to the persistent data
store represented by the given URL.public void destroy()
destroy
in interface javax.servlet.Servlet
destroy
in class javax.servlet.GenericServlet
@Deprecated public static String safeEscapeForHtml(String unsafe)
unsafe
- non-escaped stringprotected Optional<WebJarServer> getWebJarServer()
Copyright © 2019. All rights reserved.