Solved

How to display a string with empty characters in jsp?

Posted on 2009-05-19
2
453 Views
Last Modified: 2012-05-07
I am writing code to display a string which comes from a session on a jsp page..this string is 15 chars long and can have empty spaces in the beginning or the middle of the string..when i display the string..it omits the empty spaces from the beginning and the end...how can i preserve these empty places in the string when I display it on the JSP.
The string is coming in the correct format to jsp..when i print it up in the console...
<TR>
	<TD align = left>ID: <%= idString %><FONT color = "red">(<%= numd %>)</FONT>
	</TD>
</TR>
The string can be "01234ABCDEFGHIJ" or "       CDEF HIJ"
If the first string is given it is displayed as expected..problem is with the second string..please help me.

Open in new window

0
Comment
Question by:srafi78
2 Comments
 
LVL 27

Accepted Solution

by:
mrcoffee365 earned 35 total points
ID: 24427013
This is not a JSP problem, it's HTML.  If you want to display a string in an HTML page with spaces intact, you can
1) replace all the spaces with the non-breaking space character (which will turn into a space if I type it in -- ampersand nbsp semicolon)
2) wrap your string with the HTML tags <pre> and </pre>

and so on.
0
 
LVL 8

Author Closing Comment

by:srafi78
ID: 31583247
The first option worked for me..Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Export JSON response data to Excel in IE9 3 81
constuctor calling other constructor 2 80
iterator example remove 8 75
How to Make JSP Pages Responsive ? details are below 3 927
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question