Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

7.5. Using DispatcherPortlet

The DispatcherPortlet acts as the front controller in the Spring Portlet MVC framework (as shown in figure 7.2). It’s responsible for the following:

  • Sending portlet requests to the appropriate handler (explained in section 7.7). The mapping of the portlet request to an appropriate handler is specified using HandlerMapping beans (explained in section 7.8). In the Hello World portlet, this mapping is specified by the PortletModeHandlerMapping bean in the hello-World-portlet.xml file (see listing 7.5).

  • Resolving the view using ViewResolver. The InternalResourceViewResolver in listing 7.5 supports JSPs and servlets as view technologies. You can use different ViewResolvers depending upon the view technologies you’re using (such as JSP, Velocity, and FreeMarker).

  • Dispatching requests to the ViewRendererServlet to render views. The ViewRendererServlet is configured in the web application deployment descriptor (see listing 7.6), and by default it’s mapped to the URL /WEB-INF/servlet/view. The DispatcherPortlet includes the content generated by the ViewRendererServlet using the PortletRequestDispatcher object:

      include(request, response)

    In this code, viewRendererUrl is the URL to which the ViewRendererServlet is mapped.


You are currently reading a PREVIEW of this book.


Get instant access to over $1 million worth of books and videos.


Start a Free 10-Day Trial

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint