This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

printing it 2 times?  RSS feed

 
sam christopher
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi..
i am new bie to scriptlet codings..
here i in jsp page, i am trying to print "mesgbody" which is array list., from a class "ScrollMsg".
code is...

<jsp:useBean id="ScrollMsg" scope="request" class="com.sasd.bean.ScrollMsg" >

<jsp:getProperty name="ScrollMsg" property="mesgbody" />

<%
out.println(ScrollMsg.getTot());
for (int i=0;i<ScrollMsg.getTot();i++)
{
%>
<span class="title">
<% java.util.ArrayList tmp = ScrollMsg.getMesgbody();
out.println(tmp.get(i));
}
%>

</span>
</jsp:useBean>

====

and my back end bean code...


public ArrayList getMesgbody() {
FacesContext context = FacesContext.getCurrentInstance();
httpSession=(HttpSession)context.getExternalContext().getSession(false);
ArrayList tmp = new ArrayList();
UserBean usb = (UserBean) httpSession.getAttribute("UserBean");
int empId = usb.getEmpId();

try {
session = getSession();

list = session.createQuery("Select sc ......bla bla .....asc").list();


int i=0;
Object[] msgtuple;

for(Iterator it =list.iterator(); it.hasNext();){
Smessagemst row = (Smessagemst) it.next();
String msghd =row.getMsghd().toString();
tmp.add(row.getMessage());
i++;
}
setTot(i);
}
catch(Exception e){
e.printStackTrace();
}
mesgbody.addAll(tmp);

return mesgbody;
}
===

and bak end bean it not much necessary in this case.....
anyway i put for the reference....

my backend process are all fine... and coming to jsp,
"out.println(tmp.get(i));" print my required output once , before that..

<jsp:getProperty name="ScrollMsg" property="mesgbody" /> is also print the same once.. ,
but the former one is not working properly, with out the latter one...
why ?? help me
[ September 08, 2006: Message edited by: Bear Bibeault ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!