Jsp bean write nesting

Hi,
I am using struts...
In my jsp I have an set of objects which i itrerate through and display the parameters in that object1..
But the object1 has internally another object2 which has some parameters in it..
while displaying the set of object1s i have to display parameter in object2.
How can i do this ..can any body help...

<logic:notEmpty name="alertForm" property="alerts">
     <logic:iterate id="alert" name="alertForm" property="alerts">
          <tr>
               <td>
               <div align="center"><bean:write name="alert" property="alertLocalTime"/></div>
          </td>
          <td>
               <div align="center"><bean:write name="alert" property="segmentSN"/></div>
          </td>
          <td>
               <div align="center"><bean:write name="alert" property="alertAsTag"/></div>
          </td>
</tr>
     </logic:iterate>
     </logic:notEmpty>
</table>
Here in alert bean i have another object ' WorkStatus ' which has members like statusCode, name etc..
i have to print WorkStatus.statusCode in the above iterator loop..
Can you suggest how i can do this..

Similar Messages

  • How can I useStruts bean:write tag with parameter

    Helow i'm using Struts tags for reading data from beans
    for example:
    public String getUserName(){
    return name;
    in the jsp:
    <bean:write name="userInfoBean" property="userName"/>
    but i have a getter with paramer as this:
    public String getUserName(String id){
    return getNameById(id);
    How can i write the tag in the jsp???

    You can't directly.
    Your method MUST have the signature public String getUserName() in order to be identified as an attribute of the bean, accessed via the bean:write tag.
    One workaround is to set the "id" as a separate property, and then use that attribute in the getUserName method.
    ie
    int id;
    public void setUserId(int newId){
      this.id = newId;
    public String getUserName(){
      return getUserName(id);
    }

  • How to use bean:write inside jsp:include ?

    I got a problem about JSP's syntax. The following is my code:
    <%@ include file="<bean:write name="HelloForm" property="target" />"%>
    The double quotes inside bean:write is my problem. Could you please teach me how to use bean:write within JSP's include? Thank you!

    http://java.sun.com/products/jsp/syntax/1.2/syntaxref12.html
    Include Directive vs <jsp:include>
    The include directive <%@include %> is done at page translation/compile time.
    It effectively pastes in a static file, and then compiles the JSP as if it was all one file.
    As such, you cannot provide a runtime expression to it.
    To do runtime inclusion, you need to use the <jsp:include> tag which does except runtime parameters.
    <%String test = request.getParameter("pageInfo");%>
    <%String link = test + ".jsp"; %>
    <jsp:include page="<%= link %>" %>Unfortunately you can't use the tag with a bean:write tag as well, you can only use runtime expressions, not tag. So you have to do the include with
    <jsp:include page="<%= HelloForm.getTarget() %>" />
    Cheers,
    evnafets

  • Struts nesting the bean:write tag

    hi I want to nest the <bean:write tag into any other html tag
    i.e.
    <html:hidden property="color" value="<bean:write name="colorSet" property="colorValue" />"/>
    Could you tell me if I am missing any quotes or something ?
    Thanks

    You can't use custom tags as attributes to other tags.
    The correct way to do this in struts would be to populate the action form as part of the action.

  • JSP, BEANS AND DAO best practice... (and a little of STRUTS & JSTL)

    Hi,
    Want to get your opinion on how to really use bean and dao in jsp pages.
    Imagine that you wants to display a news list on the jsp index page for example.
    You've got a dao with method getLastNews(int size) which returns a Collection of News beans. Then with jstl or struts you iterate ove the collection to display the news in a formatted way.
    Easy to build collection with scriptlets & co but not very clean...
    What is the best way to call my dao and its method with a tag whithout using scriplets ?
    Thanks

    Yes this is the solution i use when the collection is displayed alone in a jsp page, but how do you do this when you include this collection in a page, and if you have other collections in other parts of the page ? Is there a clean solution of doing this in the jsp page? For example:
    <sometag:loadmycollection name="list"/>
    <logic:iterate id="myCollectionElement" name="list">
    Element Value: <bean:write name="myCollectionElement" />
    </logic:iterate>
    I know that i can write my own tag by if there is an existing solution...

  • Getting  error in using bean:write   tag

    hi ,
    in my logon.jsp i m putting
    these 2 lines
    <bean:write name="logonForm" property= "username"/>
    <html:errors/>
    i m getting error "cannot find logonForm in scope null"
    then i added scope ="request" in bean tag
    i got error "cannot find logonForm in scope null"
    my motive is to display what ever the the value user has entered as user name in logon.jsp
    ..is it possible by use of this tag ..
    plz help me in this case.
    thanks in advance.

    sorry
    after adding scope="request" i got error "cannot find logonForm in scope request"
    but
    <bean:write name="logonForm" property="username" scope="request"/>
    this tag is working fine when i placed it in jsp that is getting fwded by logon page
    thanks

  • Struts.  Using bean:write to access actionForm parameters

    While I am not new to web applications, I am fairly new to Struts.
    What I am trying to accomplish is to have a read only view of a maintenance form.
    Instead of using html:input fields to display the values in a form bean, I want to use the bean:write tag to just display their values.
    However the bean:write tag requires the "name" field, specifying which bean to display a property from.
    I am thinking of grabbing the bean from request scope (org.apache.struts.taglib.html.BEAN) and using that, but are there any better ways to accomplish what I want?
    Or is what I am attempting breaking the rules in some way, and I should desist immediately?
    cheers,
    evnafets

    I am thinking of grabbing the bean from request scope.thats fine. u r not breaking any rules.
    U can set the form bean on the page wtih <c:set> tag. This way u can use the name everywhere in that page.
    but are there any better ways to accomplish what I want?ofcourse there are different ways to achieve ur goal.
    I think of it more as a convenience issue.
    since u r not modifying the form and its attr's u could specify the scope of the form as session in the struct-config.xml and in the jsp provide the form name in the <form> tag. This way ur jsp will automatically get the relevant form bean from the session scope and u will not need the name attribute.
    sien...

  • Problem with logic:equal tag when used with bean:write

    Hi All,
    I have a problem with logic:equal.When i tried to use the following piece of code its not working
    <logic:equal name="var in session" value="<bean:write name='var in request'/>">
    Do some thing
    </logic:equal>
    its not working i know we cant use nested tags
    is thr any alternative instead of using a scriplet

    A scriptlet expression is about all you can do.
    <bean:define id="tempVar" name="var in request"/>
    <logic:equal name="var in session" value="<%= tempVar %>">
    ...If you have a JSP2.0 container with EL enabled, then you could use an EL expression instead of the standard <%= expr %>

  • Bean:write and complex types

    I have a Java object like that:
    public class OBJ1 {
    String name;
    String id;
    OBJ2 [] Array_OBJ2;
    // getters and setters methods for name,id and Array_OBJ2
    OBJ2 is an an object like this:
    public class OBJ2 {
    String surname;
    OBJ3 [] Array_OBJ3;
    // getters and setters methods for surname and Array_OBJ3
    And OBJ3 is like this:
    public class OBJ3 {
    String control;
    // getters and setters methods for control
    I passed a OBJ1 object to a jsp page and I can access to "name" and "id" properties successfully, but I have problems to access to the "Array_OBJ2" object.
    What's the correct syntax in the jsp page to access it in a bean:write tag ?

    Hi
    I am not sure just thinking and guessing try this.......
    <logic:iterate name="OBJ1" id="item" property="Array_OBJ2">
        <bean:write name="item" />
    </logic:iterate>do reply wheather it works or not

  • Bean:write

    when i use <bean:write>
    say i have "<b>Jave Struts</b>" set in the "property attribute"
    when i out put this on the jsp page using <bean:write>
    it outputs the heading exactly what i wrote....i want the <b> and </b> tags to be html compliant....
    when i "view source" i get <b> for the <b> and </b> for the </b>
    does anyone know how to solve this problem so I can get my heading in bold on my jsp page
    thanks in advance

    <bean:write filter="false" ... />
    The filter attribute specifies whether or not to escape troublesome characters.
    http://struts.apache.org/userGuide/struts-bean.html#write

  • Radiogroups + jsp + beans + struts

    I need to display a page with radiogroups (to be decided at runtime from database) using JSP.
    Basically this is an online quiz with questions & every question having 3-4 options as radio buttons.
    On submission of the form i need to access the value of the option.
    My problem is how can i submit the value in a hashtable (Quesid, RadioValue) for all the radiogroups.
    I cant go for individual getters & setters.
    Dont know any struts tag for the same.
    Kindly guide

    Yes this is the solution i use when the collection is displayed alone in a jsp page, but how do you do this when you include this collection in a page, and if you have other collections in other parts of the page ? Is there a clean solution of doing this in the jsp page? For example:
    <sometag:loadmycollection name="list"/>
    <logic:iterate id="myCollectionElement" name="list">
    Element Value: <bean:write name="myCollectionElement" />
    </logic:iterate>
    I know that i can write my own tag by if there is an existing solution...

  • Prob with running jsp Bean

    Hi,
    I am trying to run a bean through a jsp but its giving error at useBean tag of jsp:
    The error is :
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: /Quadratic.jsp(7,0) The value for the useBean class attribute com.brainysoftware.Quadratic is invalid.
         org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:150)
         org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1227)
         org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
         org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
         org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
         org.apache.jasper.compiler.Generator.generate(Generator.java:3272)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    My jsp is:
    <HTML>
    <HEAD>
    <TITLE> JSP BEAN Quadratic Example </TITLE>
    </HEAD>
    <BODY>
    <%@ page language="java" %>
    <jsp:useBean id="quadratic" scope="session" class="com.brainysoftware.Quadratic" />
    <jsp:setProperty name="quadratic" property="ia" param="a" />
    <jsp:setProperty name="quadratic" property="ib" param="b" />
    <jsp:setProperty name="quadratic" property="ic" param="c" />
    X1= <%= quad.getDx1( ) %>
    X2= <%= quad.getDx2( ) %>
    End of program
    </BODY>
    </HTML>my bean is:
    package com.brainysoftware;
    import java.io.*;
    class Quadratic{
    int ia;
    int ib;
    int ic;
    String dx1;
    String dx2;
    public int getIa( ) {
    return ia;
    public void setIa( int ii) {
    ia=ii;
    public int getIb( ) {
    return ib;
    public void setIb(int ii) {
    ib=ii;
    public int getIc( ) {
    return ic;
    public void setIc(int ii) {
    ic=ii;
    public String getDx1( ) {
    double detA;
    double result;
    detA= ib*ib -4*ia*ic;
    if(detA<0.0)
    return "Real Roots not possible";
    else {
    result= -ib - Math.sqrt(detA/(2 * ia));
    Double Dresult=new Double (result);
    return Dresult.toString( );
    public String getDx2( ) {
    double detA;
    double result;
    detA= ib*ib -4*ia*ic;
    if(detA<0.0)
    return "Real Roots not possible";
    else {
    result= -ib + Math.sqrt(detA/(2 * ia));
    Double Dresult=new Double (result);
    return Dresult.toString( );
    my directory structure is given below:
    C:\tomcat-5.0.28\jakarta-tomcat-5.0.28\webapps\jsp-examples\WEB-INF\classes\com\
    brainysoftware>dir
    Volume in drive C has no label.
    Volume Serial Number is 4C50-9542
    Directory of C:\tomcat-5.0.28\jakarta-tomcat-5.0.28\webapps\jsp-examples\WEB-IN
    F\classes\com\brainysoftware
    05/22/2005 11:15 PM <DIR> .
    05/22/2005 11:15 PM <DIR> ..
    05/22/2005 11:18 PM 134 CalculatorBean.java
    05/23/2005 12:12 AM 216 Counter.java
    05/24/2005 10:48 PM 358 SimpleJavaBean.java
    06/14/2005 11:16 PM 1,205 Calculator.java
    06/14/2005 11:16 PM 1,323 Calculator.class
    06/16/2005 06:44 PM 534 CalculatorBean2.java
    06/17/2005 08:53 AM 703 CalculatorBean2.class
    06/16/2005 07:00 PM 352 CalculatorBean2.html
    06/17/2005 08:51 AM 588 CalculatorBean2.jsp
    06/17/2005 04:29 PM 97 UploadBean.java
    06/17/2005 04:43 PM 527 FileUploadBean.java
    06/17/2005 04:43 PM 834 FileUploadBean.class
    06/18/2005 12:21 PM 863 Quadratic.java
    06/18/2005 12:21 PM 1,093 Quadratic.class
    14 File(s) 8,827 bytes
    2 Dir(s) 8,615,821,312 bytes free
    C:\tomcat-5.0.28\jakarta-tomcat-5.0.28\webapps\jsp-examples\WEB-INF\classes\com\
    brainysoftware>
    The above clearly shows the presence of Bean in the reqd directory but still I am getting an error. Can somebody help me:
    Zulfi.

    class QuadraticThe class is not public. It is only visible to other classes in the same package as itself, so the servlet (JSP) trying to instantiate and reference it can't see it.
    Make it public.

  • How to use bean write in  struts html:text tag

    hi,
    i'm new to struts concepts.here i'm trying to write a value in html struts tag using <bean:write>
    my current tag is
    <html:text property="empname" value='<bean:write name="employee" property="empid">' />
    but it gives same tag in the text box.how i can solve this.

    what am I doing wrong?You will notice above that I mentioned
    YOU CAN'T USE CUSTOM TAGS AS ATTRIBUTES TO OTHER CUSTOM TAGS
    (was that loud enough for you to notice this time)?
    Try
    <html:text styleId="instruction" styleClass="text" size="50" name="instruction" property="value"/>
    //or
    <html:text styleId="instruction" styleClass="text" size="50" property="instruction" value="<%= instruction.getValue() %>"/>
    better alternative: populate your formbean with your action and just have:
    <html:text styleId="instruction" styleClass="text" size="50" property="instruction"/>
    If you set the "instruction" property of your formBean in the action, the value will be automagically reflected here.
    Cheers,
    evnafets

  • Is there a way to put more than 1 bean:write into value?

    Hello,
    Is it possible to put something like below to value???
    <html:textarea property="desc" styleClass="metin" cols="77" rows="3" value="<bean:write property="a" name="form" /> something <bean:write property="b" name="form" /> something"/>
    thanks

    why don't you do it in your form bean and just bind a property to the textarea?

  • NEWBIE SUPER EASY JSP / BEAN

    With about half a dozen books sitting around my desk, I can't get a REAL basic jsp to work. I FINALLY got tomcat to NOT give run time errors, however the web page simply outputs "This is output:" I know I am an idiot, but this JSP / bean stuff is upsetting. Any help on the following code would be great.
    basic.jsp is as follows:
    <jsp:useBean id="myBean" class="basic.basicbean" scope="session"/>
    <html>
    <head>
    <title>
    A Simple JSP
    </title>
    </head>
    <body>
    <%
    myBean.setBasicName("Michelle");
    %>
    This is output: <% myBean.getBasicName();%>
    </body>
    </html>
    basicbean.java is as follows:
    package basic;
    import java.beans.*;
    public class basicbean {
    private String BasicName=null;
    /** Creates new basicbean */
    public basicbean() {}
    public String getBasicName() {
    return this.BasicName;
    public void setBasicName(String value) {
    this.BasicName = value;
    Made the .java into the class put it in the basic directory under the classes/basic directory of the WEB-INF. The JSP page loads, but only output is: "This is output:" I am using Tomcat as the JSP server. "Core JSP" "Core Servlets and JavaServer Pages" "Advanced JavaServer Pages" "JSP, Servlets, and MySQL", and "Java Server Pages for Dummies" and I still can't get it. Thanks for helping out an idiot.
    -Jim

    You are very close; just a small error in the line:
    This is output: <% myBean.getBasicName();%>
    The problem is your just simply calling the method and tossing the return value. You have three ways of outputing the bean property:
    This is output: <% out.print(myBean.getBasicName();%>
    or
    This is output: <%=myBean.getBasicName()%>
    or
    This is output: <jsp:getProperty name="myBean" property="BasicName" />
    If you use the <jsp:getProperty> approach, then you must have a <jsp:useBean> somewhere above the getProperty tag.
    - Chris

Maybe you are looking for

  • MXF read errors in CC 2014.1

    Has anyone else noticed a sudden onset of MXF read errors after updating to the latest version of Premiere?  I'm getting the dreaded "Red Frames" on footage that works fine in the previous version (2014.0).  The problem doesn't occur on import, meani

  • Slow moving material

    Hi, Can anyone wil give me an idea how to calculate the slow moving material for the last 3 and 6 months with out inbuilt report and without using no of records fields provided by SAP.. can we calculate based on  the good issue based on last 3 and 6

  • Yesterday double clicked home button and all of my apps disappeared; cannot shut off i-pad, and syncing it does not restore apps or enable me to use it again. Help!

    Yesterday double clicked home button and all of my apps disappeared; cannot shut off i-pad, and syncing it does not restore apps or enable me to use it again. Help!

  • Adobe PCR form missing: Request Transfer

    MSS PCR type SPTR When the PCR type is chosen from MSS in the portal, ("Edit form"), all that comes up in Adobe Reader is an under construction-type form that says: This form has not yet been completely created.  Therefore you cannot currently use th

  • Long sms 6310i

    At this moment i have a Nokia 6310i but it seems not possible to write a long sms. Also when receiving a longer sms this text is split and is received in several short (160) sms. Is ther any setting I can change to resolve this problem? Thx