Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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

whitspaces

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know whether this should go in the JSP section or HTMl section but I decided to ask my question here, because it has more to do with HTML i think. But anyways I have this Jsp that prints out 2 string on a line in a table. I want to add white space between the 2 strings to make it look neater. Can someone how I can do this. Thank you. Here is how some of my code looks (I want to add the spaces between ant and the call to getNextAntenna() )
<html>
<head><title>AntennaLister2</title></head>
<body>
<h1>AntennaLister2</h1>
<form><table><tr><td><select name="siteId" size=5>
<%
testAntenna();
String ant;
int count = 0;
while(true) {
ant = getNextAntenna();
if(ant != null)
{
out.println( "<option>" + ant + getNextAntenna() );
}
else
{
break;
}
}%>
</select><td></tr></table></form>

</body>
</html>
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:
out.println( "<option>" + ant + " " + getNextAntenna() );
The   is used to print a space to the html page that is displayed, for more spaces just use more of the   .
hope that helps
 
Chanpreet Julka
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried that but html condenses all the whitespaces. It doesn't end up giving me any extra spaces. Any other ideas? I think it has something to do with  , but not quite sure how to use it here. Thank you.
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that post, I thought that because html was turned off, what I typed would print correctly. Where you see a space in my post it should be &_nbsp; (there should be no underscore, I had to put it in so the UBB wouldn't turn it into a space again).
You can chain them together to get multiple spaces. If you were only looking for a single space it should have worked though because the browser should leave single spaces alone and only ignore anyhing after the first.
 
Chanpreet Julka
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem. ive done it like this but it gives me errors.
out.println( "<option>" + ant +   + getNextAntenna() );
Any help? Thanks
 
Chanpreet Julka
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i wrote the wrong post i actually did it like this
out.println( "<option>" + ant +   + getNextAntenna() );
and it doesnt work
 
Chanpreet Julka
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i wrote the wrong post i actually did it like this
out.println( "<option>" + ant +   + getNextAntenna() );
and it doesnt work
 
Chanpreet Julka
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i see what the problem is.. the html on this page is messing up.. but where I have the blank space after ant + is actually where i write the nbsp, and i get errors. thanks
 
Chanpreet Julka
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it to work. Thank you for your help
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually nbsp doesnt work in netscape(4.7 anyway)
you should use #160 instead
[ June 18, 2002: Message edited by: Randall Twede ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic