Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Preston Thornton
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • 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.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37234
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!