Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loop Porblems in JSP

 
bat ken
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Halo

I am having a problem here, hope someone can help me My loop keep on replace the value in my variable. I want to get few lines of sentence, but I only able to print out/get the last sentence. It keep on replacing...

my code;
--------
for (int i=0; i < Cnt; i++)
{
if (request.getParameter("status"+arrOfRec_to_update[i]).equals ("R") && i==0)
{
Body="This is to inform you that your Material Requisition was REJECTED on "
+dte+
" by "
+SenderREJ+
"\n\n"
+"Details"+
"\n"
+"No."+" | "+"Material Item Code"+" | "+"Material Description"+" | "+"Qty/UM"+" | "+"Reason"+"\n"
+cnt+"|"+mtr_cde+"|"+in_desc_combine+"|"+qty+umdesc+"|"+pur+"|"+rec_status+"|"+remark+"\n"
+"\n"
+"Regards"+
"\n"+"BCT";
rCnt = rCnt + 1;
}
else if(request.getParameter("status"+arrOfRec_to_update[i]).equals ("R") && i!=0)
{
Body=cnt+"|"+mtr_cde+"|"+in_desc_combine+"|"+qty+umdesc+"|"+pur+"|"+rec_status+"|"+remark;
rCnt = rCnt + 1;
}
}

Thank you
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using "Body="
You should initialize Body to an empty string and use "Body += ".

Instead, use a StringBuffer and call the append() method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic