?
Solved

struts logical custom tag issues

Posted on 2012-08-16
7
Medium Priority
?
1,416 Views
Last Modified: 2012-08-20
I am trying following struts custom logical tag example and getting error as in the attachment. Please advise on how to resolve it.
Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<html>

<BODY>
      <P>
            <logic:present name="account" property="bankName" scope="session">
                  <h3>
                        The name of the bank is
                        <bean:write name="account" property="bankName" scope="session" />
                  </h3>
            </logic:present>
            <logic:notPresent name="account" property="branchNumber"
                  scope="session">
                  <h3>The branch number is not available</h3>
            </logic:notPresent>
            <logic:equal name="account" property="accountDetail.accountType"
                  scope="session" value="Checkings">
                  <h3>The total checkings balance is $2000.20</h3>
            </logic:equal>
            <logic:notEqual name="account" property="accountDetail.accountType"
                  scope="session" value="Checkings">
                  <h3>No Checkings account</h3>
            </logic:notEqual>
            <logic:notEmpty name="account" property="creditCards" scope="session">
                  <logic:iterate id="card" name="account" property="creditCards"
                        scope="session">
                        <bean:write name="card" property="name" />
                        <bean:write name="card" property="number" />
                  </logic:iterate>
            </logic:notEmpty>
      </P>
</BODY>
</html>
StrutsLogicalTag.JPG
0
Comment
Question by:gudii9
  • 4
  • 3
7 Comments
 
LVL 10
ID: 38301478
can you remove the scope="session" and try. Please go through the link for reference

http://www.dzone.com/tutorials/java/struts/struts-example/struts-logic-tag-example-1.html
0
 
LVL 7

Author Comment

by:gudii9
ID: 38301865
it still says

description The server encountered an internal error (javax.servlet.ServletException: javax.servlet.jsp.JspException: No bean found under attribute key account) that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: No bean found under attribute key account
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: No bean found under attribute key account
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
      org.apache.jsp.jsps.struts.LogicTagsDemo_jsp._jspService(LogicTagsDemo_jsp.java:200)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
JSP.JPG
0
 
LVL 10
ID: 38301983
please check in struts-config.xml whether formbean Account has been configured or not?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 7

Author Comment

by:gudii9
ID: 38302131
yes. I wonder why it is looking for account.
<?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-bean name="customerForm" type="formbeans.CustomerForm">
            </form-bean>

      </form-beans>
      <!-- Global Exceptions -->
      <global-exceptions></global-exceptions>
      <!-- Global Forwards -->
      <global-forwards></global-forwards>
      <!-- Action Mappings -->
      <action-mappings>
      
            
             <action path="/customer" name="customerForm" validate="true"
                  input="/jsps/struts/CustomerDetails.jsp" scope="request"
                  type="actions.CustomerAction">
                  <forward name="success" path="/jsps/struts/Confirmation.jsp" />

            </action>

            <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>
0
 
LVL 10
ID: 38302239
Because according to the below

 <logic:present name="account" property="bankName" scope="session">
                  <h3>
                        The name of the bank is
                        <bean:write name="account" property="bankName" scope="session" />
                  </h3>
            </logic:present>

The  name="account" is the account object.
0
 
LVL 7

Author Comment

by:gudii9
ID: 38304876
It worked after removing the session. I wonder why session caused issue. Please advise
0
 
LVL 10

Accepted Solution

by:
krishna kishore mellacheruvu venkata earned 2000 total points
ID: 38305038
According to the syntax  i think there is no scope attribute in the logic tags.


http://www.dzone.com/tutorials/java/struts/struts-example/struts-logic-tag-example-1.html
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question