This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

new line character in JSP  RSS feed

 
Murli Prasad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66257
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!