• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

new line character in JSP

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to call a method from a java bean which calls the status variable in the JSP page.

However I need to insert the newline character in the JSP Form.

In java bean, I am using the following method:
for(int i=0 ; i < uniqueList.size() ; i++)
{
String tmp=(String)uniqueList.get(i);
temp=temp+tmp+'\n';
}
I wish to display the string in multiple lines according to the number of iterations

But when the variable is called in JSP and I use it in the following manner:
<tr><td><%= status %> </td></tr>

It prints simply as a single string in a single line.

Please help.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should set the list in the request, and loop through it in JSP, using JSTL's forEach tag.
In the loop. you can then output a <tr> tag for each iteration.

However, if it's not what you're looking for, if you want only one tr tag, you can replace

by
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remeber that the purpose of a JSP is to create an HTML document to send to the browser. And since newlines are not significant in HTML, they have no effect on the display of the page.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic