Request forwarding

Notice how text displayed in the previous section's example matches the value of the value attribute of the checkboxes that were clicked and not the labels displayed on the previous page. This might confuse the users. Let's modify the servlet to change these values so that they match the labels, then forward the request to another servlet that will display the confirmation message in the browser.

The new version of MultipleValueFieldHandlerServlet is shown as follows:

package net.ensode.javaee8book.formhandling; import java.io.IOException; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; ...

Get Java EE 8 Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.