• Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting String to HTML  RSS feed

 
Raj Mehta
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSP page on which I want to display a String which is extracted from the request (request.getParameter())

The String has new line characters ('\n') which i want to convert to respective html values like <br/> or <p/>.

What is the best way in Java to do this??
 
Jeffrey Hunter
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the String method replaceAll(String regex, String replacement) which searches for matches to the regular expression regex, and replaces them with replacement.


[ July 02, 2004: Message edited by: Jeffrey Hunter ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!