This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 60810
    
  65

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]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Displaying blank spaces between two words
 
Similar Threads
No scrolling in text input after uppercase ?
ORA-01000: maximum open cursors exceeded
IE not taking &nbsp; characters
JSPException
Need Help With Dynamic text box in JSP