Render HTML markup from database using Struts tag

Hi all,

The situation is, I have specific database fields which hold html markup elements. I am accessing them using struts framework and tlds. Could anybody tell me how would I render the html markup from those bean properties?

I appreciate your help.

Ta.

[281 byte] By [jini4javaa] at [2007-11-27 10:16:39]
# 1

use can use the <bean:write .../> tags to do that, just make sure you set the filter attribute to false, otherwise it will escape all your HTML. so you would use it like so...

<bean:write property="myHTMLString" filter="false"/>

den2681a at 2007-7-28 15:46:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hey...

Thanks. It worked.

Other question for you, if you don't mind....

Why one should use a Collection object which contains javabean objects (one for each for each database row) over ResultSet object in MVC? What are the advantage on not using ResultSet in MVC at presentation layer?

I hope my question is clear enough.

Cheers.

jini4javaa at 2007-7-28 15:46:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

It doesn't really matter I guess, however the .jsp is really the View part of MVC, so it should really just be comprised of struts tag and no scriptlets (no code inside the <% ... %> tags).

Think of it this way, if you are going to display a row of data why not make an object for the class, like EmployeeRow which can hold all the strings and data you need to display. Then, in your action class (the Controller part of MVC) you would convert the ResultSet into a useable EmployeeRow and build a Collection of them to display on the screen. The code is much easier to maintain this way since you won't have to make tons of changes if the display part ever changes, all you'd have to change is the EmployeeRow class and that would in turn affect all the rows.

Make sense?

den2681a at 2007-7-28 15:46:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...