public class WicketServlet
extends javax.servlet.http.HttpServlet
WicketFilter
if you require advanced chaining of resources.
Servlet class for all wicket applications. The specific application class to instantiate should be specified to the application server via an init-params argument named "applicationClassName" in the servlet declaration, which is typically in a web.xml file. The servlet declaration may vary from one application server to another, but should look something like this:
<servlet> <servlet-name>MyApplication</servlet-name> <servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-class> <init-param> <param-name>applicationClassName</param-name> <param-value>com.whoever.MyApplication</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>Note that the applicationClassName parameter you specify must be the fully qualified name of a class that extends WebApplication. If your class cannot be found, does not extend WebApplication or cannot be instantiated, a runtime exception of type WicketRuntimeException will be thrown. As an alternative, you can configure an application factory instead. This looks like:
<init-param> <param-name>applicationFactoryClassName</param-name> <param-value>teachscape.platform.web.wicket.SpringApplicationFactory</param-value> </init-param>and it has to satisfy interface
IWebApplicationFactory
.
The servlet can also be configured to skip certain paths, this is especially useful when the
servlet is mapped to /*
mapping:
<init-param> <param-name>ignorePaths</param-name> <param-value>/images/products/,/documents/pdf/</param-value> </init-param>
When GET/POST requests are made via HTTP, a WebRequestCycle object is created from the request, response and session objects (after wrapping them in the appropriate wicket wrappers). The RequestCycle's render() method is then called to produce a response to the HTTP request.
If you want to use servlet specific configuration, e.g. using init parameters from the
ServletConfig
object, you should override the init() method of
GenericServlet
. For example:
public void init() throws ServletException { ServletConfig config = getServletConfig(); String webXMLParameter = config.getInitParameter("myWebXMLParameter"); ...In order to support frameworks like Spring, the class is non-final and the variable webApplication is protected instead of private. Thus subclasses may provide their own means of providing the application object.
RequestCycle
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected WicketFilter |
wicketFilter
The WicketFilter where all the handling is done
|
Constructor and Description |
---|
WicketServlet() |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Servlet cleanup.
|
void |
doGet(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse)
Handles servlet page requests.
|
void |
doPost(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse)
Calls doGet with arguments.
|
void |
init()
Servlet initialization
|
protected WicketFilter |
newWicketFilter() |
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
protected transient WicketFilter wicketFilter
public final void doGet(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse) throws javax.servlet.ServletException, IOException
doGet
in class javax.servlet.http.HttpServlet
servletRequest
- Servlet request objectservletResponse
- Servlet response objectjavax.servlet.ServletException
- Thrown if something goes wrong during request handlingIOException
public final void doPost(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse) throws javax.servlet.ServletException, IOException
doPost
in class javax.servlet.http.HttpServlet
servletRequest
- Servlet request objectservletResponse
- Servlet response objectjavax.servlet.ServletException
- Thrown if something goes wrong during request handlingIOException
doGet(HttpServletRequest, HttpServletResponse)
public void init() throws javax.servlet.ServletException
init
in class javax.servlet.GenericServlet
javax.servlet.ServletException
protected WicketFilter newWicketFilter()
public void destroy()
destroy
in interface javax.servlet.Servlet
destroy
in class javax.servlet.GenericServlet
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.