Tuesday, January 04, 2011

JSF 2.x Forwarding Request to a Servlet

The question of how to forward a JSF Request to a server was something that came up the other day. I have some legacy servlets which will handle some of the information which is being generated from my JSF pages.

So I decided to write an example of how to do it. The example is designed to go from a JSF page to a servlet which will process the headers and display the information. The alternate example passes the request to a servlet which then passes it back to another JSF page for display. The example also demonstrates using a <f:param /> to pass additional information. The project was done using NetBeans and Maven 2.

Note: The project files can be downloaded from Bitbucket here: jsf-servlet-forwarding

As you can see from the images, the forms are very simple and used for demonstration only.
JSF Request Form


JSF -Servlet -JSF Response


This file has some interesting syntax which a number of people may not be used to seeing, for example #{param['form1:inputText1']} which is using Expression Language (EL) to read the param[] and find the specific form element which is in single quotes.

Servlet Response




Popular Posts