wood burning stoves 2.0*
The moose likes JSP and the fly likes Displaying blank spaces between two words Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Displaying blank spaces between two words" Watch "Displaying blank spaces between two words" New topic
Author

Displaying blank spaces between two words

Waez Ali
Ranch Hand

Joined: Jan 24, 2005
Posts: 43
Hi,

At runtime I am suppose to set balnk spaces before some text which is to be displayed on page.

While constructing viewbean I am writing code like as below.


However when I display the text on my jsp it's getting displayed as follows

 runtime text
Can someone suggest me how to do this ?
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

How are you putting that bean text to your JSP page, Put that code.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Waez Ali
Ranch Hand

Joined: Jan 24, 2005
Posts: 43
In the above message the blank space in the code are   which got converted to blank space
Waez Ali
Ranch Hand

Joined: Jan 24, 2005
Posts: 43
Hi Sagar,

I am using cut to print that text field on my jsp.

In may post the actuall code got converted to balnk spaces, that is not blank but the symbol used in html to put blank space.
Soniya Ahuja
Ranch Hand

Joined: Jul 20, 2008
Posts: 83
Hey Waez,
The <cut> has attribute escapeXml who's default value is true. YOu need to set it explicitly as false. ONly then the blank spaces will be printed


SCJP 1.5 | SCWCD 5 | SCJP 6.0
[url]http://a2zjava.webs.com[/url] - Online training for Java/JSPs and Servlets/SCJP/SCWCD
http://soniyaahuja.webs.com
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Multiple blank spaces will always be collapsed to a single space by the browsers. It has nothing to do with JSP or <cut> or even how many spaces there are in the HTML. That's just the way HTML works.

You should be adjusting the position of elements with CSS, not spaces.

If you really need multiple spaces, you'll need to encode them as non-breaking space entities: &nbsp;. The browser will not collapse multiple entities the way it will multiple whitespace characters.
[ July 30, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying blank spaces between two words