<jsp:useBean id="formbean" class="myTest.FormBean"/>
<jsp:setProperty name="formbean" property="*"/>
Field1: <jsp:getProperty name="formbean" property="field1"/>
If the data posted is some "html coding",
eg. <font color="red">red</font>...
result is really show a "red" red in the browser.
But I wanna show <font color="red">red</font> in fact.
How can i encode it with some HTML transformation?
eg. < to replace "<" or > to replace ">"
I dun wanna use some string replace in the JavaBean as this will reduce its reusable power.
Looking for ur help. Thank you.
If you are not too strict about not having java code in your page:
<% String color = formbean.getField1()%>
If you don't want to replace string in the javabean for better reusability, you may write a custom tag to replace string. Just enclose the getProperty insdie the custom tag. That would provide you the best reusabiliy.
I just wonder why such useful function for markup language which not in jsp/servlet api.
Also, theServerside.com has htmlencode function (there is in ASP). Can webmaster share this with me?