wicket.protocol.http
Class WicketServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by wicket.protocol.http.WicketServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
WicketPortletServlet

public class WicketServlet
extends javax.servlet.http.HttpServlet

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>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.

When GET/POST requests are made via HTTP, an 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 ServletConfigobject, 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 there own means of providing the application object.

Author:
Jonathan Locke, Timur Mehrvarz, Juergen Donnerstag, Igor Vaynberg (ivaynberg)
See Also:
RequestCycle, Serialized Form

Field Summary
static java.lang.String APP_FACT_PARAM
          The name of the context parameter that specifies application factory class
protected  WebApplication webApplication
          The application this servlet is serving
 
Constructor Summary
WicketServlet()
           
 
Method Summary
 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.
protected  IWebApplicationFactory getApplicationFactory()
          Creates the web application factory instance.
protected  long getLastModified(javax.servlet.http.HttpServletRequest servletRequest)
           
 void init()
          Servlet initialization
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, service, 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
 

Field Detail

APP_FACT_PARAM

public static final java.lang.String APP_FACT_PARAM
The name of the context parameter that specifies application factory class

See Also:
Constant Field Values

webApplication

protected WebApplication webApplication
The application this servlet is serving

Constructor Detail

WicketServlet

public WicketServlet()
Method Detail

doGet

public final void doGet(javax.servlet.http.HttpServletRequest servletRequest,
                        javax.servlet.http.HttpServletResponse servletResponse)
                 throws javax.servlet.ServletException,
                        java.io.IOException
Handles servlet page requests.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
servletRequest - Servlet request object
servletResponse - Servlet response object
Throws:
javax.servlet.ServletException - Thrown if something goes wrong during request handling
java.io.IOException

doPost

public final void doPost(javax.servlet.http.HttpServletRequest servletRequest,
                         javax.servlet.http.HttpServletResponse servletResponse)
                  throws javax.servlet.ServletException,
                         java.io.IOException
Calls doGet with arguments.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
servletRequest - Servlet request object
servletResponse - Servlet response object
Throws:
javax.servlet.ServletException - Thrown if something goes wrong during request handling
java.io.IOException
See Also:
doGet(HttpServletRequest, HttpServletResponse)

init

public void init()
Servlet initialization

Overrides:
init in class javax.servlet.GenericServlet

destroy

public void destroy()
Servlet cleanup.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

getApplicationFactory

protected IWebApplicationFactory getApplicationFactory()
Creates the web application factory instance. If no APP_FACT_PARAM is specified in web.xml ContextParamWebApplicationFactory will be used by default.

Returns:
application factory instance
See Also:
ContextParamWebApplicationFactory

getLastModified

protected long getLastModified(javax.servlet.http.HttpServletRequest servletRequest)
Overrides:
getLastModified in class javax.servlet.http.HttpServlet
See Also:
HttpServlet.getLastModified(javax.servlet.http.HttpServletRequest)


Copyright © 2004-2007 Wicket developers. All Rights Reserved.