OrderEntryServlet.jsp.

Power Java
Techniques for Optimizing Web Site Development and Runtime Characteristics

Christopher A. Fregly
Listing 8. OrderEntryServlet.jsp.


public
void doPost( HttpServletRequest request, HttpServletResponse response ){
//Retrieve NavigationFacility instance (implemented as a Singleton)
NavigationFacility nav = NavigationFacility.getInstance()

String navAction = request.getParameter( "navAction" );
String currentSceneName = request.getParameter( "currentSceneName" );

if ( ( navAction != null ) && ( currentSceneName != null ) ){
  if ( navAction.equals( "SubmitOrderAction" ) ){
			//[Insert order validation and submit here...]
			//Assume order is valid and submitted to back end
			//successfully...

			//Set the next scene based on the selected Take: current
			//scene, the action taken, and the result
			TransitionSelector selector = new TransitionSelector(
			currentSceneName, navAction, "Success" );
			nav.selectTransition( selector );
  }
  else
  if ( navAction.equals( "CancelOrderAction" ) ){
//[Insert cancel order here...]
//Assume cancel order is successful...
TransitionSelector selector = new TransitionSelector(
                         currentSceneName, navAction, "Success" );
nav.selectTransition( selector );
  }

  //Redirect to the helper JSP
  response.sendRedirect( "WebDirectorHelper.jsp" );
}
}

About the Author

Christopher A. Fregly is Senior Cunsultant for BEA Systems Inc. in Chicago. He can be contacted at chris@fregly.