• 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

How to format JSP Output Similar to System.out.println

Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good morning everyone,

I am exploring the use of JSP coding with command utilities and have found some quick success. I am, however, having issues with formatting out with from the following code sample:

This output is misaligned and looks like this:

Hello World of Java

Volume in drive C has no label. Volume Serial Number is 749D-D60E Directory of C:\Users\Preston 3rd\Desktop\eclipse-jee-mars-R-win32\eclipse 01/08/2016 03:50 AM . 01/08/2016 03:50 AM .. 06/03/2015 07:07 PM 60 .eclipseproduct 06/09/2015 06:42 AM 1,434 about.html 08/02/2015 07:55 AM 1,160,346 artifacts.xml 01/08/2016 03:50 AM configuration 07/12/2015 10:29 AM dropins 06/21/2015 12:08 PM 326,640 eclipse.exe 08/02/2015 07:56 AM 477 eclipse.ini 06/21/2015 12:08 PM 31,728 eclipsec.exe 02/20/2015 04:35 AM 12,637 epl-v10.html 08/02/2015 07:55 AM features 05/11/2015 02:55 PM 6,297 notice.html 01/08/2016 03:49 AM p2 08/02/2015 07:55 AM plugins 07/12/2015 10:30 AM readme 8 File(s) 1,539,619 bytes 8 Dir(s) 381,339,762,688 bytes free Done

I have tried trim() and replaceall() but without success. Any help would be very appreciated.
author & internet detective
Posts: 41147
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First up, read Why not use Scriptlets.

You'd still have this problem without scriptlets though as HTML is getting rid of your whitespace. Take a look at the <pre> tag in HTML. It preserves the formatting.
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic