Printing saved HTML to jsp keeps getting corrupted

Posted by JWL on Stack Overflow See other posts from Stack Overflow or by JWL
Published on 2014-08-21T21:29:25Z Indexed on 2014/08/21 22:20 UTC
Read the original article Hit count: 214

Filed under:
|
|
|

I have a JAVA object where I save a HTML string value I call message. The saved data looks like the below,

You have received a new <a href='' onclick='return popupRentalView('5282053859835904');'>Rental Request 5282053859835904</a>.  Please view your open orders.

But when printed to the JSP file and displayed at runtime using

<%=pm.getMessage()%>

or

<%out.print(pm.getMessage());%>

The actual html code comes out all messed up,

You have received a new <a 5282053859835904');'="" onclick="return popupRentalView(" href="">Rental Request 5282053859835904</a>

. Please view your open orders.

Any thoughts on why the displayed string does not match the saved string?

JAVA code for saving is

note.setMessage("You have received a new <a href=\"\" onclick='return popupRentalView('"
            + requestId
            + "');'> Rental Request "
            + requestId
            + "</a>.  Please view your open orders.");

© Stack Overflow or respective owner

Related posts about java

Related posts about JavaScript