Sure,
        all you have to do is write a method on the bean like

public String getHTML() {
        return ("<b>Hello World</b>");
}

and then put the tags

<jsp:useBean id="myBean" class="myBean" scope="page" />
<jsp:getProperty name="myBean" property="HTML"/>

in the JSP.  But this brings up a question I have been struggling with:
What is the better way of generating html, having the bean do it through a
method or including it in the JSP.  I know that it is the intention of the
JSP designers to seperate HTML from Java code and vis-versa but for example
you have a bean which represents multiple choices that a user has made.  do
you:

        1) have a single method on the bean that returns the
"<select>...</select>

        or

        2) put in the jsp
        <select name=<jsp:expr>mySelectBean.getName()</jsp:expr>>
        <% for(int i=0;i<mySelectBean.getNumberOfItems();i++) { %>
                <option><jsp:expr>mySelectBean.getName()</jsp:expr></option>
        ....
        </select>

        now 1) seems to obfuscate some code from the HTML designer, but two
seems pretty much like Java code in the JSP  which is better?  opinions?

                                Brendan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to