JavaBean with JSP


Web tier: servlets, JSP, Web frameworks: JavaBean with JSP

  1. JavaBean with JSP (4 messages)

    <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. &lt; to replace "<" or &gt; 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.

    Threaded Messages (4)

  2. JavaBean with JSP[ Go to top ]

    If you are not too strict about not having java code in your page:
    <% String color = formbean.getField1()%>
    <font color="<%=color%>"><%=color%></font>
  3. JavaBean with JSP[ Go to top ]

    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.
  4. JavaBean with JSP[ Go to top ]

    thank you.
    I just wonder why such useful function for markup language which not in jsp/servlet api.
  5. JavaBean with JSP[ Go to top ]

    Also, has htmlencode function (there is in ASP). Can webmaster share this with me?