Link to home
Start Free TrialLog in
Avatar of komlaaa
komlaaa

asked on

<action forward request on jsp page is null

This is a continuation of:question Q_23427531.html  At
https://www.experts-exchange.com/questions/23427531/action-forward-struts.html

my Action class and failure.jsp page  look like shown below.

when i am forwarded to failure.jsp, my screen shows:
Errors occurred:
null

meaning there were no exception, but i am unable to print the request set in action class JUST go to success page,  Also see, customer.jsp and a snippet of strut-config.xml



try {
    	request.setAttribute("errorMessage" , "++++++ Before HibernateTransaction");
			// perform list customer operations
			CommandExecutor.getInstance().executeHibernateCommand(
							new CreateCustomer(currentCustomer));
			request.setAttribute("customer",currentCustomer );
		request.setAttribute("Inside try block -- customer", currentCustomer );
		}
    	catch (Exception e) 
    	{
    		System.out.println("######Inside catch block########");
    		request.setAttribute("errorMessage", "#Inside catch block#" + e.getMessage());
			throw new ServletException(e);
		}
    	
    	request.setAttribute("errorMessage", "everything seem fine -- After Catch block");
		return mapping.findForward("success");
 
	}
 
failure.jsp look
 
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Failure has occurred</title>
</head>
<body>
 
<B>Errors occurred: <br></B>
<%= request.getParameter("errorMessage") %>
<html:errors/>
</body>
</html>
 
===== strut-config snippet =====
<action 
      path="/createCustomer"      
      name="createCustomerForm"
      input="/form/createCustomer.jsp"
      scope="request"       
      type="actions.CreateCustomerAction">
      <forward name="success" path="/form/createdOrder.jsp" />
      <forward name="failure" path="/failure.jsp"></forward>
    </action>
 
======== customer.jsp where the request comes from ==========
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
 
<html> 
	<head>
		<title>JSP for CreateCustomerForm form</title>
	</head>
	<body>
		<html:form action="/createCustomer"  method="post">
			Email : <html:text property="email"/><html:errors property="email"/><br/>
			FirstName : <html:text property="firstName"/><html:errors property="firstName"/><br/>
			LastName : <html:text property="lastName"/><html:errors property="lastName"/><br/>
			<html:submit/><html:cancel/>
		</html:form>
	</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of summerian
summerian
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial