Tim Fox wrote:
> [...]
> So... most strings that we display on jsp pages have to first be put
> through a method which converts all these 'strange characters' to their
> html escape sequences (& goes to & < goes to <) - the method is
> just a big case statement.
>
> The question is: Where do I call this method? Do I:
>
> a) Put it in the business object? I'd rather not since that's mixing
> presentation with business logic [...]
> b) Use result beans? [...]
> c) Do the parsing in the page?
>
> <jsp:useBean id='customer' class='...' />
> <h1>Here is the customer</h1>
> <%=Utils.parseString(customer.getName()); %>
> [...]
> Looking forward to hearing some ideas...
I'm in favor of c), because the business object should not know about
HTML, and separate result beans seem like overkill (in most situation,
I'm sure there are cases when they make sense).
An alternative to c), to avoid scriptlets, is to develop a custom
action that works like <jsp:getProperty> but that also formats the
value in an HTML friendly way:
<jsp:useBean id='customer' class='...' />
<h1>Here is the customer</h1>
<foo:getFormattedProperty name="customer" property="name" />
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets