Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Carriage Returns in Request Dispatcher attribute.

 
Hazel Sisson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I'm not sure if this in the right forum, but I'm sure the sheriffs will move it if it's not!
I'm sending a string (s8) to a JSP using RequestDispatcher. What I want to do is put some carriage returns into the string, along with elements from entries[n]. This is how I tried at first:
for (int n = 0; n < NR_OF_PARAMS; n++)
{
if (entries[n] == "ERROR")
{
final Character ocChar = new Character((char)10);
final String svENTER = new String(ocChar.toString());
String s8 = s8.concat(svENTER + labels[n]);
entries[n] = "";
}
}
This displays the string with the correct elements from entries[n] added on, but it's all on one line. I have also tried putting \n in place of svENTER but that didn't work either!
Any ideas?
Thank-you,
Hazel
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are displaying it on an HTML (or JSP)page, then you need to use <br> tags, not java \n characters.

If you do a 'view source' on the page, you'll see that the \n worked, but of course a browser ignores them as 'whitespace', and only an HTML <br> will cause the output to do a 'new line'
[ April 04, 2002: Message edited by: Mike Curwen ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic