Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Read & Write a file in a jsp page without modifying the alignment  RSS feed

 
Sam Jimzz
Greenhorn
Posts: 28
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone guide me how to print a file in jsp page without changing the alignment of the text..?

Eg: while uploading,

Java Ranch
Friendly Place
for
greenhorns


But,while in reading and writing into a jsp page.,it prints as,

Java Ranch Friendly Place for greenhorns

how to Preserve the alignment ..?
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTML, which is what JSPs generate, handle whitespace differently. Any occurrence of one or more whitespace characters (including line breaks) are treated as one single space, unless they are in a <pre> block. To include a line break in non-<pre> blocks you should use <br>.
 
Sam Jimzz
Greenhorn
Posts: 28
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:HTML, which is what JSPs generate, handle whitespace differently. Any occurrence of one or more whitespace characters (including line breaks) are treated as one single space, unless they are in a <pre> block. To include a line break in non-<pre> blocks you should use <br>.


Is that like this in the http://htmlhelp.com/reference/html40/block/pre.html

or

Could you please elaborate it using an example..
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's exactly what I meant with the <pre> block.

An example with <br> is easy. Just put the following into a simple HTML file and view it in your browser:
 
Sam Jimzz
Greenhorn
Posts: 28
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob..

I tried with your assistance & its working.

But the issue is.,whenever the file has a long lines,a part of the long line is omitted while printing that page.

when i tried to check for 80-100 characters in each line., the alignment in the page making a big difference.Specially in the case of paragraphs..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!