• Post Reply Bookmark Topic Watch Topic
  • New Topic

Replacing a Special Character With Carriage Return and Line Feed  RSS feed

 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have placed the '^' in strings where there were originally carriage returns and line feeds.

Now I want to display them on the web page by replacing the '^' back to carriage return and line feed

I have tried the following but I get an error the the EL cannot be parsed

eRTNotes is a session Attribute

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JSP forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the error, exactly. Paraphrasing isn't helpful.
 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:What's the error, exactly. Paraphrasing isn't helpful.


JSPG0122E: Unable to parse EL function ${fn:replace(eRTNotes,'^','\r\n')}
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, that wasn't as helpful as I had hoped.

I had hoped that it would have called out the fact that you can't insert special characters into EL string literals. The only escapable characters in EL string literals are the single and double quotes, as well as the backslash itself.

This sort of data scrubbing should be done before the data gets sent to the JSP.

Remember, we want to keep the JSPs as "dumb" as possible. Do as much as you can before the JSP gets invoked so that what needs to be done within the JSP is just the display of the data (without the need to massage it).
 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Remember, we want to keep the JSPs as "dumb" as possible. Do as much as you can before the JSP gets invoked so that what needs to be done within the JSP is just the display of the data (without the need to massage it).


I can't even get the replace to work at the class level



Returns:

[4/27/10 16:18:29:272 CDT] 00000025 SystemOut O Notes:
Test^Test3^Test6
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ^ character has a special meaning in regular expressions. You'll need to escape it.
 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:The ^ character has a special meaning in regular expressions. You'll need to escape it.


Thanks once again and God Bless.

I am sure you'll here from me again sooner that you desire to.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!