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/Programming/Languages/Java/J2EE/JSP/Q_23427531.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

Java EEJSP

Avatar of undefined
Last Comment
summerian

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
summerian

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23