This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi all, I have a servlet which takes in a string entered by the user and displays it in HTML. This is all working unless the string has a space in it, in which cases the string is cut at the space. I know the escape character for the " is "quot;" and was wondering if there was a similar on for spaces? Or is it the way I am including the variable in the HTML?
the space is displayed using &_#32 or &_nbsp. the first is prefereable. in my servlet i built the message into one string before displaying it. welcome = "Welcome " + value; "</h2> out.println("<html>" + "<head><title>Welcome</title></head>" + "<body background='../clouds.jpg'><h2>" + welcome +
dont know if any of that will help. not even sure the html is displayed properly in my servlet even because ive never logged on using a name with a space in it. [ September 16, 2003: Message edited by: Randall Twede ]
I believe what Mani was trying to say is that the entity for a non-breaking space is . (Please proof-read your responses after posting). However, I don't think that that might be the correct solution to your problem. You didn't really show where the problem is manifesting itself in your page. You might just need to quote your attributes (which you should always do in any case). For example instead of generating:
be sure to generate:
Or better yet, after processing in the servlet forward to a JSP page for your display where such things are easier to keep straight. hth, bear