Hi,
I have a page called index.jsp that takes the username and password.
The form is submitted to a
servlet that verifies the username and password. If they are valid, I use a sendRedirect to redirect the request to an action(ViewAccountDetailsAction) inside my
Struts 1.3 application.
I am using the ViewAccountDetailsForm class as my ActionForm. This has been associated with the above action class in the struts-config.xml file.
ViewAccountDetailsForm.java
import java.util.List;
import org.apache.struts.action.ActionForm;
import pojos.login.AccountDetails;
public class ViewAccountDetailsForm extends ActionForm {
private static final long serialVersionUID = 1L;
private List<AccountDetails> accountsList;
public List<AccountDetails> getAccountsList() {
return accountsList;
}
public void setAccountsList(List<AccountDetails> accountsList) {
this.accountsList = accountsList;
System.out.println("This is the size of accountList of ViewAccountDetailsForm "+this.accountsList.size());
}
}
ViewAccountDetailsAction.java method inside which the account details are gathered.
import interfaces.login.ViewAccountDetailsInterface;
public ActionForward viewDtls(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
//check for SessionActivity
HttpSession session = request.getSession();
if(null!=session){
if(null!=session.getAttribute("username")){
System.out.println("OSR");
System.out.println(session.getAttribute("username").toString());
ViewAccountDetailsForm viewAcctDtlForm = (ViewAccountDetailsForm) form;
ViewAccountDetailsInterface viewAccountDetails = new ViewAccountDetailsBean();
viewAcctDtlForm.setAccountsList(viewAccountDetails.getAccountDetails
(session.getAttribute("username").toString()));
return mapping.findForward("launch");
}
else
return mapping.findForward("sessionexpired");
}
else
return mapping.findForward("sessionexpired");
}
launch.jsp - file on which all my account details must be displayed
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<logic:empty name="ViewAccountDetailsForm" property="accountsList">
The accountsList is empty
</logic:empty>
<logic:present name="ViewAccountDetailsForm" property="accountsList">
<%out.write("OSR: Present cleared"); %>
<table border="1px" bordercolor="blue">
<tr>
<td>Account Number</td>
<td>Account Balance</td>
</tr>
<logic:iterate id="accountDetail" name="ViewAccountDetailsForm" property="accountsList">
<tr>
<td><bean:write name="accountDetail.accountId"/></td>
<td><bean:write name="accountDetail.accountBalance"/></td>
</tr>
</logic:iterate>
</table>
</logic:present>
<%out.write("Outside write"); %>
</body>
</html>
Problem:
I am getting Can't find ViewAccountDetailsForm bean in any scope
Can someone suggest a work around?