File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes print value outside while loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "print value outside while loop" Watch "print value outside while loop" New topic
Author

print value outside while loop

somu sharma
Greenhorn

Joined: Mar 26, 2012
Posts: 6
I want to print values in html table outside while loop. I can not do it in while loop since my header gets repeated for each iteration.
I want something like...
NAME COUNTRY PHONENO
abc USA 0000000
pqr AUS 1111111

I have my code like ,
Iterator myItr = list.iterator();
while(myItr.hasNext()){
Object[] obj= (Object[]) myItr.next();
String myName = (String) obj[0];
String myCountry =(String)obj[1];
String myPhone =(String)obj[2];
data = "<html><body><TABLE><tr><td><b>NAME</td><td><b>COUNTRY</td><td><b>PHONENO</td></tr><tr><td>"+myName+"</td><td>"+myCountry+"</td><td>"+myPhone"+</td></tr></TABLE></body></html>";
out.print(data);
}

Here header part is also repeated again n again.
the output is coming as ,
NAME COUNTRY PHONENO
abc USA 0000000
NAME COUNTRY PHONENO
pqr AUS 1111111
NAME COUNTRY PHONENO
xyz AUS 2222222
Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196
Hi You can achieve the desired result from the following code.

somu sharma
Greenhorn

Joined: Mar 26, 2012
Posts: 6
Piyush Mangal wrote:Hi You can achieve the desired result from the following code.


Thanks it worked.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: print value outside while loop