Solved

How to display a string with empty characters in jsp?

Posted on 2009-05-19
2
455 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article outlines some of the reasons why an email message gets flagged as spam on a recipient's end.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

707 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