We help IT Professionals succeed at work.

struts custom tags

gudii9
gudii9 asked
on
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

Author

Commented:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
      <!-- Data Sources -->
      <data-sources></data-sources>
      <!-- Form Beans -->
      <form-beans>
            <form-bean name="loginForm" type="formbeans.LoginForm">
            </form-bean>
            
      </form-beans>
      <!-- Global Exceptions -->
      <global-exceptions></global-exceptions>
      <!-- Global Forwards -->
      <global-forwards></global-forwards>
      <!-- Action Mappings -->
      <action-mappings>
            <action path="/welcome" forward="/jsps/struts/Welcome.jsp" />
            <action path="/maintenance" type="actions.MaintenanceAction">
                  <forward name="sales" path="/jsps/struts/Sales.jsp" />
                  <forward name="inventory" path="/jsps/struts/Inventory.jsp" />
            </action>
            <action path="/login" name="loginForm" type="actions.LoginAction">
                  <forward name="success" path="/jsps/struts/Main.jsp" />
            </action>
            <action path="/customTags" type="actions.BeanAction">
                  <forward name="bean" path="/jsps/struts/BeanTagsDemo.jsp" />
            </action>
      </action-mappings>
      <!-- Message Resources -->
      <message-resources parameter="myprops.MyStruts"/>
</struts-config>

struts config looks above

getting erros like

HTTP Status 500 - org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.

--------------------------------------------------------------------------------

type Exception report

message org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.

description The server encountered an internal error (org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.) that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.
      org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
      org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
      org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause

org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.
      org.apache.struts.chain.commands.AbstractSelectAction.execute(AbstractSelectAction.java:71)
      org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
      org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
      org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
      org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
      org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
      org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
      org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


note The full stack trace of the root cause is available in the Apache Tomcat/7.0.29 logs.


--------------------------------------------------------------------------------
please advise

Author

Commented:
Is it case sensitive. With capital T it worked fine

Explore More ContentExplore courses, solutions, and other research materials related to this topic.