Using servlets only to extract view input data.

Enterprise Java
Architecting and Designing Scalable, Multitier Systems
by Michael Minh Nguyen
Listing 2. Using servlets only to extract view input data.

package com.scalablemultitier;

import javax.servlet.*;
import javax.servlet.http.*;

public class registerUserScalableApproach extends HttpServlet
  public void doPost (HttpServletRequest request, HttpServlet-
      Response response) throws ServletException, IOException
    User user;
    UserController userController;
    String firstName, middleInitial, lastName, email;

    firstName = request.getParameter ("firstName");
    middleInitial = request.getParameter ("middleInitial");
    lastName = request.getParameter ("lastName");
    email = request.getParameter ("email");
    userController = new UserController ();
    user = userController.registerUser (firstName, middleInitial,
 lastName, email);
    if (user != null)
      request.getSession (true).setAttribute ("User", user);
      request.getRequestDispatcher (
      forward (request, response);
      request.getRequestDispatcher (
      forward (request, response);

About the Author

Michael Minh Nguyen is a senior software engineer at eBuilt Inc. in Irvine, CA. He may be contacted at [email protected].