The ViewRendererServlet - Java-Springs

The rendering process in Portlet MVC is a bit more complex than in Web MVC. In order to reuse all the view technologies from Spring Web MVC, we must convert the Portlet Request / Portlet Response to Http Servlet Request / Http Servlet Response and then call the render method of the View. To do this, DispatcherP ortlet uses a special servlet that exists for just this purpose: the View Renderer Servlet.

In order for Dispatcher Portlet rendering to work, you must declare an instance of the View Renderer Servlet in the web.xml file for your web application as follows:


To perform the actual rendering, DispatcherPortlet does the following:

  1. Binds the Web Application Context to the request as an attribute under the same WEB_APPLICATION_CONTEXT_ATTRIBUTE key that Dispatcher Servlet uses.
  2. Binds the Model and View objects to the request to make them available to th View Renderer Servlet.
  3. Constructs a Portlet Request Dispatcher and performs an include using the /WEBINF/ servlet/view URL that is mapped to the View Renderer Servlet.

The View Renderer Servlet is then able to call the render method on the View with the appropriate arguments.

The actual URL for the View Renderer Servlet can be changed using Dispatcher Portlet’s view Renderer Url configuration parameter.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

Java-Springs Topics