File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Read & Write a file in a jsp page without modifying the alignment Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "Read & Write a file in a jsp page without modifying the alignment" Watch "Read & Write a file in a jsp page without modifying the alignment" New topic
Author

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

Sam Jimzz
Greenhorn

Joined: Apr 30, 2011
Posts: 13

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 ..?


God Loves You and will never love you less.
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18370

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>.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Sam Jimzz
Greenhorn

Joined: Apr 30, 2011
Posts: 13

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
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18370

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

Joined: Apr 30, 2011
Posts: 13

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..
 
IntelliJ Java IDE
 
subject: Read & Write a file in a jsp page without modifying the alignment
 
Threads others viewed
Be nice to Greenhorn!
Use of XML
Hindi thread.
Library - convert Java to UML
JavaRanch stewardship and SEO
IntelliJ Java IDE