Advertisement
Advertisement
| 05.24.2008 at 07:21AM PDT, ID: 23429832 |
|
[x]
Attachment Details
|
||
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>
|