• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Blank spaces in html:options tag

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Currently i am facing one problem with html ptions tag.When i use html ptions tag within html:select tag the values specified in html ptions tag are trimmed.

I mean to say if the string array which i am passing to html ptions contains string like this "a b",then its spaces are truncated and the values is coming as "a b" in browser(basically it is convetrting multiple spaces into one space).

How to solve this problem??Any ideas??
 
Bartender
Posts: 9615
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to draw your attention to the following option which is available when you post:

If you disable smilies, your posts will be more readable.
As for your problem, HTML ignores consecutive white space. Space characters, tabs, carriage returns and so on are concatenated into a single space.
The solution will depend on exactly what you are trying to do. Can you give us some more detail.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe is right about HTML automatically truncating spaces. However, you can tell it not to do that by providing non-breaking spaces. You do that with the characters:

& n b s p ;


If you want eight spaces between words, just repeat the above characters eight times. (Naturally, you shouldn't put spaces between them as I did.)
 
Surya Kant
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
Basically I am working on struts application.When user do some operation i will make a call to some action file.In Action file i set some values to string array and i set this to formbean values.So when i get it in the browser the spaces will be trimmed.
Let me explain you with example..
In Action file
String []strArry = new String[]{"a","b","a b"};
I will set this value to formbean
formBean.setXXX(strArray);

In JSP,i use this value in html:options tag.
the 3rd variable in strArray i.e,"a b" is coming as "a b";
Why is this coming??Can i change its behaviour??

Actually i tried putting " "in action file before setting it to formbean..But i didnt get the proper results..
 
Marshal
Posts: 67430
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question has already been answered. HTMl will collapse whitespace. If you want multiple white-space characters, you must use the   HTML character entity.
    Bookmark Topic Watch Topic
  • New Topic