Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

br and &nbsp displayed when the page reloads  RSS feed

 
Raji Sriram
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a JSP page where the user can enter values and save the data.
When the page reloads I see br and nbsp displayed with the text.
I tried logging the user entered values in the server side. It displays properly.
I also did out.println separately inside the JSP. This also displays the text properly. But when I assign that text to a textbox, these tags show up.
Any clues?
Thanks,
Raji.
[ February 01, 2004: Message edited by: Raji Sriram ]
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell us how you are displaying your textarea data in yout JSP? Ideally, please include the appropriate fragment of your JSP.
I'm guessing that you are using cut, which does an implicit "escaping" of these sort of characters.
you will probably need to check the "Disable smilies in this post", to make sure that you don't get little faces appearing in your code
[ January 26, 2004: Message edited by: Frank Carver ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The text area does not use <br> tags
You are going to have to replace them with the equivilant break of \n which is supported by the element.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric wrote: The text area does not use <br> tags
Well, it doesn't use them as markup to layout the textarea, sure. But it's quite likely that someone might want to enter (and subsequently edit) HTML or XML in a textarea.
In my site editing and blogging tool Barrel, I often need to enter page fragments into a text area. When I subsequently edit one of those fragments, I certainly don't want all the < characters to be changed to &lt;.
 
Raji Sriram
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eric, Frank for your replies.
This is the fragment of my code.
<%
// getting the value from server side object
String textAreaVal = myObj.getTextAreaVal();
String textVal = myObj.getTextVal();
out.println("textAreaVal = " + textAreaVal );
out.println("textVal = " + textVal );

%>
<html>
<body>
<input type=textbox name= "myTextBox" value='<%= textVal %>' >
<input type=textbox value='<%= textVal %>'>
<TEXTAREA NAME="myTextArea"> <%= textAreaVal %> </TEXTAREA>
</body>
</html>
Well, when I submit this, the textbox and the textarea values go to the server side properly and I am able to log them. When I reload the page, I am able to see the values proplerly using the out.println. But, when I put the values in the textbox or textarea, I see the nbsp and br tags.
Please advise if you have seen this earlier.
Thanks,
Raji.
[ January 27, 2004: Message edited by: Raji Sriram ]
[ January 27, 2004: Message edited by: Raji Sriram ]
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, an immediate work-around would seem to be to do something like:

Have you tried that?
 
Raji Sriram
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the suggestion Frank. I will try that.
Regards,
Raji.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!