This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
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

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
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!