We help IT Professionals succeed at work.
Get Started

struts custom tags

gudii9
gudii9 asked
on
932 Views
Last Modified: 2012-08-17
I am trying to run following JSP with Struts custom tags. I am getting exception as in attachment



message An exception occurred processing JSP page /jsps/struts/BeanTagsDemo.jsp at line 7 4: <P> 5: <h2> Accessing the Account bean properties from the session </h2></BR> 6: <bean:define id="ssn" value="324324" /> 7: <bean:write name="account" property="accountDetail.accountType" 8: scope="session"/> 9: <bean:write name="account" property="accountDetail.accountBalance" 10: scope="session"/> Stacktrace:

description The server encountered
BeanTagsDemo.jsp




<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<html>
<BODY>
<P>
<h2> Accessing the Account bean properties from the session </h2></BR>
<bean:define id="ssn" value="324324" />
<bean:write name="account" property="accountDetail.accountType"
scope="session"/>
<bean:write name="account" property="accountDetail.accountBalance"
scope="session"/>
Chapter 16 JSP development using Struts Tags
Struts
475
<br/>
<bean:write name="account" property="address.addressLine1" scope="session"/>
<bean:write name="account" property="address.city" scope="session"/>
<bean:write name="account" property="address.state" scope="session"/>
<bean:write name="account" property="address.country" scope="session"/>
<br/>
<bean:write name="account" property="creditCards[0].name" scope="session"/>
<bean:write name="account" property="creditCards[0].number"
scope="session"/> </br>
<bean:write name="account" property="creditCards[1].name" scope="session"/>
<bean:write name="account" property="creditCards[1].number"
scope="session"/>
<bean:write name="ssn" />
<h2>Messages from property files</h2><br/>
<bean:message key="title" /><br/>
<bean:message key="error.username" /><br/>
<bean:message key="error.password" />
</P>
</BODY>
</html>




CreditCArd.java



package beans;
public class CreditCard {
      String name;
      String number;
      public String getName() {
            return name;
      }
      public void setName(String name) {
            this.name = name;
      }
      public String getNumber() {
            return number;
      }
      public void setNumber(String number) {
            this.number = number;
      }
}

Address.java

package beans;
public class Address {
      String addressLine1;
      String city;
      String state;
      String country;
      public String getAddressLine1() {
            return addressLine1;
      }
      public void setAddressLine1(String addressLine1) {
            this.addressLine1 = addressLine1;
      }
      public String getCity() {
            return city;
      }
      public void setCity(String city) {
            this.city = city;
      }
      public String getCountry() {
            return country;
      }
      public void setCountry(String country) {
            this.country = country;
      }
      public String getState() {
            return state;
      }
      public void setState(String state) {
            this.state = state;
      }
}



AccountDetail.java
package beans;
public class AccountDetail {
      String accountType;
      String accountBalance;
      public String getAccountBalance() {
            return accountBalance;
      }
      public void setAccountBalance(String accountBalance) {
            this.accountBalance = accountBalance;
      }
      public String getAccountType() {
            return accountType;
      }
      public void setAccountType(String accountType) {
            this.accountType = accountType;
      }
}

Account.java

package beans;
import java.util.List;
public class Account {
      AccountDetail accountDetail;
      Address address;
      List creditCards;
      String bankName;
      
      public String getBankName() {
            return bankName;
      }
      public void setBankName(String bankName) {
            this.bankName = bankName;
      }
      public AccountDetail getAccountDetail() {
            return accountDetail;
      }
      public void setAccountDetail(AccountDetail accountDetail) {
            this.accountDetail = accountDetail;
      }
      public Address getAddress() {
            return address;
      }
      public void setAddress(Address address) {
            this.address = address;
      }
      public List getCreditCards() {
            return creditCards;
      }
      public void setCreditCards(List creditCards) {
            this.creditCards = creditCards;
      }
      public CreditCard getCreditCards(int pos) {
            return (CreditCard) creditCards.get(pos);
      }
      public void setCreditCards(int pos, CreditCard card) {
            this.creditCards.add(pos, card);
      }
}


Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
StrutsCustomTags.JPG
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE