File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Loop Porblems in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Loop Porblems in JSP" Watch "Loop Porblems in JSP" New topic

Loop Porblems in JSP

bat ken

Joined: Dec 28, 2005
Posts: 24

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 "
" by "
+"No."+" | "+"Material Item Code"+" | "+"Material Description"+" | "+"Qty/UM"+" | "+"Reason"+"\n"
rCnt = rCnt + 1;
else if(request.getParameter("status"+arrOfRec_to_update[i]).equals ("R") && i!=0)
rCnt = rCnt + 1;

Thank you
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

You are using "Body="
You should initialize Body to an empty string and use "Body += ".

Instead, use a StringBuffer and call the append() method.

[My Blog]
All roads lead to JavaRanch
I agree. Here's the link:
subject: Loop Porblems in JSP
It's not a secret anymore!