You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by kal inuganti <we...@yahoo.com> on 2003/03/19 22:46:08 UTC

Tag Handler Independent of HTML

Hi All,

I am building a "State Option List" and my current implementation has the US States as a String Array and I build a String using the elements of this String Array. I use a JspWriter to write this String to the output.

Here is a sample code that appends the array elements to a string buffer -

String s = STATES[i];
           
stringbuffer.append("<option value=\"");
stringbuffer.append(s);
stringbuffer.append("\"");

But, I am embedding HTML in Java. Is there a better way of doing this? Any suggestions will be greatly appreciated.

Thanks, -k

 



---------------------------------
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!

Re: Tag Handler Independent of HTML

Posted by Sloan Seaman <sl...@sgi.net>.
put the States array into the page context and then use some sort of
iterator tag to build the options list in the jsp

If you are using Struts you could get the States array into a collection and
use the <logic:iterator> or even <html:options> tags to do what you want to
do in the .jsp itself....

If you are not doing JSP, then you may want to look at Velocity templates...

----- Original Message -----
From: "kal inuganti" <we...@yahoo.com>
To: <ta...@jakarta.apache.org>
Sent: Wednesday, March 19, 2003 4:46 PM
Subject: Tag Handler Independent of HTML


>
> Hi All,
>
> I am building a "State Option List" and my current implementation has the
US States as a String Array and I build a String using the elements of this
String Array. I use a JspWriter to write this String to the output.
>
> Here is a sample code that appends the array elements to a string buffer -
>
> String s = STATES[i];
>
> stringbuffer.append("<option value=\"");
> stringbuffer.append(s);
> stringbuffer.append("\"");
>
> But, I am embedding HTML in Java. Is there a better way of doing this? Any
suggestions will be greatly appreciated.
>
> Thanks, -k
>
>
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org