Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Carriage Returns in Request Dispatcher attribute.  RSS feed

 
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
 
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!