You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sushil jain <su...@yahoo.com> on 2003/07/04 08:26:12 UTC
NewBie:Populating objects in Jsp
Hello,
I am new to struts and Jsp and facing a very basic problem :-
The requirement is that on submit of APFM01.jsp page I do some business processing and populate a ArrayList in the action Class APFM01Action. Now I want to display the contents of the ArrayList as table in the second page APFM02.jsp. I am trying to do so by using the iterate tag in the APFM02.jsp but getting the following errors :-
Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] E:\jakarta-tomcat-4.1.24\work\Standalone\localhost\myProject\APFM02_jsp.java:424: cannot resolve symbol
[javac] symbol : class APFM01Action
[javac] location: class org.apache.jsp.APFM02_jsp
[javac] APFM01Action pupilList = null;
[javac] ^
[javac] E:\jakarta-tomcat-4.1.24\work\Standalone\localhost\myProject\APFM02_jsp.java:431: cannot resolve symbol
[javac] symbol : class APFM01Action
[javac] location: class org.apache.jsp.APFM02_jsp
[javac] pupilList = (APFM01Action) pageContext.findAttribute("pupilList");
[javac] ^
[javac] E:\jakarta-tomcat-4.1.24\work\Standalone\localhost\myProject\APFM02_jsp.java:457: cannot resolve symbol
[javac] symbol : class APFM01Action
[javac] location: class org.apache.jsp.APFM02_jsp
[javac] pupilList = (APFM01Action) pageContext.findAttribute("pupilList");
[javac] ^
[javac] 3 errors
In the APFM01Action class Iam doing the following :-
SAXParser myParser = new MySAXParser();
myParser.ParseXML(browse);
ArrayList pupilList= myParser.listPupil();
request.setAttribute("PUPIL_LIST",pupilList);
return(mapping.findForward("success"));
The APFM02.jsp code is as follows :-
<logic:iterate id="pupilList" name= "PUPIL_LIST" type="APFM01Action">
<tr align="left">
<td>
<bean:write name="pupilList" property="upn" />
</td>
<td>
and the Struts-config file is as follows :-
<form-bean name="APFM01Form"
type="APFM01Form"/>
<form-bean name="APFM02Form"
type="APFM02Form"/>
</form-beans>
<!-- ========== Action Mapping Definitions ============================== -->
<action-mappings>
<action path="/APFM01"
type="APFM01Action"
name="APFM01Form"
input="/APFM01.jsp"
scope="session">
<forward name="success" path="/APFM02.jsp"/>
<forward name="failure" path="/APFM01.jsp"/>
</action>
<action path="/APFM02"
type="APFM02Action"
name="APFM02Form"
scope="request">
</action>
Thanks
Sushil
---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
Re: NewBie:Populating objects in Jsp
Posted by Nicolas De Loof <ni...@cgey.com>.
Yeah, I get the first point !
Are you ready for the next question ?
Nico.
> Nicolas obviously types quicker then me :-)
>
> Steve
>
> > -----Original Message-----
> > From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com]
> > Sent: July 3, 2003 11:45 PM
> > To: Struts Users Mailing List
> > Subject: Re: NewBie:Populating objects in Jsp
> >
> >
> > 1.
> > <logic:iterate> type attribute is uses to set the java type of a
> > JSP variable set by the tag for current item. By
> > default type is java.lang.Object, and if you don't use scriptlets
> > (<% java %>) or Runtime Expression (<%= java %>) you
> > don't need to use it.
> >
> > In the case you want to use type attribute, JSP has to import
> > type declaration using a JSP directive <% @page
> > import="...." %>.
> >
> > In your case, I don't think PUPIL_LIST items are APFM01Action instances.
> >
> > 2.
> > id attribute is used to set the name of a JSP variable and a page
> > scoped bean for the current item. In your case, it
> > should be a "pupil", not a "pupilList".
> >
> >
> >
> > Nico.
> >
> > > The APFM02.jsp code is as follows :-
> > >
> > > <logic:iterate id="pupilList" name= "PUPIL_LIST" type="APFM01Action">
> > > <tr align="left">
> > > <td>
> > > <bean:write name="pupilList" property="upn" />
> > > </td>
> > > <td>
> > >
> > > and the Struts-config file is as follows :-
> > >
> > > <form-bean name="APFM01Form"
> > > type="APFM01Form"/>
> > > <form-bean name="APFM02Form"
> > > type="APFM02Form"/>
> > > </form-beans>
> > >
> > > <!-- ========== Action Mapping Definitions
> > ============================== -->
> > > <action-mappings>
> > > <action path="/APFM01"
> > > type="APFM01Action"
> > > name="APFM01Form"
> > > input="/APFM01.jsp"
> > > scope="session">
> > > <forward name="success" path="/APFM02.jsp"/>
> > > <forward name="failure" path="/APFM01.jsp"/>
> > > </action>
> > > <action path="/APFM02"
> > > type="APFM02Action"
> > > name="APFM02Form"
> > > scope="request">
> > > </action>
> > >
> > > Thanks
> > > Sushil
> > >
> > >
> > > ---------------------------------
> > > Do you Yahoo!?
> > > SBC Yahoo! DSL - Now only $29.95 per month!
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: NewBie:Populating objects in Jsp
Posted by Steve Raeburn <st...@ninsky.com>.
Nicolas obviously types quicker then me :-)
Steve
> -----Original Message-----
> From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com]
> Sent: July 3, 2003 11:45 PM
> To: Struts Users Mailing List
> Subject: Re: NewBie:Populating objects in Jsp
>
>
> 1.
> <logic:iterate> type attribute is uses to set the java type of a
> JSP variable set by the tag for current item. By
> default type is java.lang.Object, and if you don't use scriptlets
> (<% java %>) or Runtime Expression (<%= java %>) you
> don't need to use it.
>
> In the case you want to use type attribute, JSP has to import
> type declaration using a JSP directive <% @page
> import="...." %>.
>
> In your case, I don't think PUPIL_LIST items are APFM01Action instances.
>
> 2.
> id attribute is used to set the name of a JSP variable and a page
> scoped bean for the current item. In your case, it
> should be a "pupil", not a "pupilList".
>
>
>
> Nico.
>
> > The APFM02.jsp code is as follows :-
> >
> > <logic:iterate id="pupilList" name= "PUPIL_LIST" type="APFM01Action">
> > <tr align="left">
> > <td>
> > <bean:write name="pupilList" property="upn" />
> > </td>
> > <td>
> >
> > and the Struts-config file is as follows :-
> >
> > <form-bean name="APFM01Form"
> > type="APFM01Form"/>
> > <form-bean name="APFM02Form"
> > type="APFM02Form"/>
> > </form-beans>
> >
> > <!-- ========== Action Mapping Definitions
> ============================== -->
> > <action-mappings>
> > <action path="/APFM01"
> > type="APFM01Action"
> > name="APFM01Form"
> > input="/APFM01.jsp"
> > scope="session">
> > <forward name="success" path="/APFM02.jsp"/>
> > <forward name="failure" path="/APFM01.jsp"/>
> > </action>
> > <action path="/APFM02"
> > type="APFM02Action"
> > name="APFM02Form"
> > scope="request">
> > </action>
> >
> > Thanks
> > Sushil
> >
> >
> > ---------------------------------
> > Do you Yahoo!?
> > SBC Yahoo! DSL - Now only $29.95 per month!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: NewBie:Populating objects in Jsp
Posted by Nicolas De Loof <ni...@cgey.com>.
1.
<logic:iterate> type attribute is uses to set the java type of a JSP variable set by the tag for current item. By
default type is java.lang.Object, and if you don't use scriptlets (<% java %>) or Runtime Expression (<%= java %>) you
don't need to use it.
In the case you want to use type attribute, JSP has to import type declaration using a JSP directive <% @page
import="...." %>.
In your case, I don't think PUPIL_LIST items are APFM01Action instances.
2.
id attribute is used to set the name of a JSP variable and a page scoped bean for the current item. In your case, it
should be a "pupil", not a "pupilList".
Nico.
> The APFM02.jsp code is as follows :-
>
> <logic:iterate id="pupilList" name= "PUPIL_LIST" type="APFM01Action">
> <tr align="left">
> <td>
> <bean:write name="pupilList" property="upn" />
> </td>
> <td>
>
> and the Struts-config file is as follows :-
>
> <form-bean name="APFM01Form"
> type="APFM01Form"/>
> <form-bean name="APFM02Form"
> type="APFM02Form"/>
> </form-beans>
>
> <!-- ========== Action Mapping Definitions ============================== -->
> <action-mappings>
> <action path="/APFM01"
> type="APFM01Action"
> name="APFM01Form"
> input="/APFM01.jsp"
> scope="session">
> <forward name="success" path="/APFM02.jsp"/>
> <forward name="failure" path="/APFM01.jsp"/>
> </action>
> <action path="/APFM02"
> type="APFM02Action"
> name="APFM02Form"
> scope="request">
> </action>
>
> Thanks
> Sushil
>
>
> ---------------------------------
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: NewBie:Populating objects in Jsp
Posted by Steve Raeburn <st...@ninsky.com>.
See below...
> -----Original Message-----
> From: sushil jain [mailto:sushil_struts@yahoo.com]
> Sent: July 3, 2003 11:26 PM
> To: Struts Users Mailing List
> Subject: NewBie:Populating objects in Jsp
>
>
> Hello,
> I am new to struts and Jsp and facing a very basic problem :-
> The requirement is that on submit of APFM01.jsp page I do some
> business processing and populate a ArrayList in the action Class
> APFM01Action. Now I want to display the contents of the ArrayList
> as table in the second page APFM02.jsp. I am trying to do so by
> using the iterate tag in the APFM02.jsp but getting the following
> errors :-
> Since fork is true, ignoring compiler setting.
> [javac] Compiling 1 source file
> [javac] Since fork is true, ignoring compiler setting.
> [javac]
> E:\jakarta-tomcat-4.1.24\work\Standalone\localhost\myProject\APFM0
> 2_jsp.java:424: cannot resolve symbol
> [javac] symbol : class APFM01Action
> [javac] location: class org.apache.jsp.APFM02_jsp
> [javac] APFM01Action pupilList = null;
> [javac] ^
> [javac]
> E:\jakarta-tomcat-4.1.24\work\Standalone\localhost\myProject\APFM0
> 2_jsp.java:431: cannot resolve symbol
> [javac] symbol : class APFM01Action
> [javac] location: class org.apache.jsp.APFM02_jsp
> [javac] pupilList = (APFM01Action)
> pageContext.findAttribute("pupilList");
> [javac] ^
> [javac]
> E:\jakarta-tomcat-4.1.24\work\Standalone\localhost\myProject\APFM0
> 2_jsp.java:457: cannot resolve symbol
> [javac] symbol : class APFM01Action
> [javac] location: class org.apache.jsp.APFM02_jsp
> [javac] pupilList = (APFM01Action)
> pageContext.findAttribute("pupilList");
> [javac] ^
> [javac] 3 errors
>
> In the APFM01Action class Iam doing the following :-
>
> SAXParser myParser = new MySAXParser();
> myParser.ParseXML(browse);
> ArrayList pupilList= myParser.listPupil();
> request.setAttribute("PUPIL_LIST",pupilList);
> return(mapping.findForward("success"));
>
> The APFM02.jsp code is as follows :-
>
> <logic:iterate id="pupilList" name= "PUPIL_LIST" type="APFM01Action">
Type should be the type of object that is your List (e.g. Pupil) , not the
Action type.
You probably don't even need to specify a type here because <bean:write>
will use introspection to access the properties.
Incidentally, 'pupil' might be a better value for the id because you are
only accessing a single pupil in each iteration, not a list.
> <tr align="left">
> <td>
> <bean:write name="pupilList" property="upn" />
> </td>
> <td>
>
> and the Struts-config file is as follows :-
>
> <form-bean name="APFM01Form"
> type="APFM01Form"/>
> <form-bean name="APFM02Form"
> type="APFM02Form"/>
> </form-beans>
>
> <!-- ========== Action Mapping Definitions
> ============================== -->
> <action-mappings>
> <action path="/APFM01"
> type="APFM01Action"
> name="APFM01Form"
> input="/APFM01.jsp"
> scope="session">
> <forward name="success" path="/APFM02.jsp"/>
> <forward name="failure" path="/APFM01.jsp"/>
> </action>
> <action path="/APFM02"
> type="APFM02Action"
> name="APFM02Form"
> scope="request">
> </action>
>
> Thanks
> Sushil
>
>
> ---------------------------------
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
Steve
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org