Spring Framework

org.springframework.web.servlet
Class ViewRendererServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.springframework.web.servlet.ViewRendererServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class ViewRendererServlet
extends javax.servlet.http.HttpServlet

ViewRendererServlet is a bridge servlet, mainly for the Portlet MVC support.

For usage with Portlets, this Servlet is necessary to force the portlet container to convert the PortletRequest to a ServletRequest, which it has to do when including a resource via the PortletRequestDispatcher. This allows for reuse of the entire Servlet-based View support even in a Portlet environment.

The actual mapping of the bridge servlet is configurable in the DispatcherPortlet, via a "viewRendererUrl" property. The default is "/WEB-INF/servlet/view", which is just available for internal resource dispatching.

Since:
2.0
Author:
William G. Thompson, Jr., John A. Lewis, Juergen Hoeller
See Also:
Serialized Form

Field Summary
static java.lang.String MODEL_ATTRIBUTE
          Name of request attribute that holds the model Map
static java.lang.String VIEW_ATTRIBUTE
          Name of request attribute that holds the View object
static java.lang.String WEB_APPLICATION_CONTEXT_ATTRIBUTE
          Request attribute to hold current web application context.
 
Constructor Summary
ViewRendererServlet()
           
 
Method Summary
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  void processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Process this request, handling exceptions.
protected  void renderView(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Retrieve the View instance and model Map to render and trigger actual rendering.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEB_APPLICATION_CONTEXT_ATTRIBUTE

public static final java.lang.String WEB_APPLICATION_CONTEXT_ATTRIBUTE
Request attribute to hold current web application context. Otherwise only the global web app context is obtainable by tags etc.

See Also:
RequestContextUtils.getWebApplicationContext(javax.servlet.ServletRequest)

VIEW_ATTRIBUTE

public static final java.lang.String VIEW_ATTRIBUTE
Name of request attribute that holds the View object


MODEL_ATTRIBUTE

public static final java.lang.String MODEL_ATTRIBUTE
Name of request attribute that holds the model Map

Constructor Detail

ViewRendererServlet

public ViewRendererServlet()
Method Detail

doGet

protected final void doGet(javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response)
                    throws javax.servlet.ServletException,
                           java.io.IOException
Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException

doPost

protected final void doPost(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response)
                     throws javax.servlet.ServletException,
                            java.io.IOException
Overrides:
doPost in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException

processRequest

protected final void processRequest(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response)
                             throws javax.servlet.ServletException,
                                    java.io.IOException
Process this request, handling exceptions. The actually event handling is performed by the abstract renderView() template method.

Throws:
javax.servlet.ServletException
java.io.IOException
See Also:
renderView(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

renderView

protected void renderView(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)
                   throws java.lang.Exception
Retrieve the View instance and model Map to render and trigger actual rendering.

Parameters:
request - current HTTP request
response - current HTTP response
Throws:
java.lang.Exception - in case of any kind of processing failure
See Also:
View.render(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

Spring Framework