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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 14687

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
Similar Threads
Unexpected operator sequence
Problem with MySQL syntax
Problems with counting short and long words
Update more than one rows through one Submit/Update Button