Solved

How to display a string with empty characters in jsp?

Posted on 2009-05-19
2
454 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
rebasing and merging used in SCM 1 84
some methods private some are not 8 230
iterator example remove 8 75
best way to search/remove a file from an EAR file 3 119
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Invest in your employees with these five simple steps to improve employee engagement and retention.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

739 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