Advertisement

05.24.2008 at 07:21AM PDT, ID: 23429832
[x]
Attachment Details

<action forward request on jsp page is null

Asked by komlaaa in Jakarta Struts, Java Server Pages (JSP), Java Servlets

This is a continuation of:question Q_23427531.html  At
http://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


Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
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>
 
 
[+][-]05.24.2008 at 10:53AM PDT, ID: 21639771

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Jakarta Struts, Java Server Pages (JSP), Java Servlets
Sign Up Now!
Solution Provided By: summerian
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628