I saw this code in the o'reilly servlet book and adapted it.
/**
* Convert a properties List into a URL query string
*
* @param props Properties list.
* @return The URL-encoded properties list as a URL query string.
*/
public static String toEncodedString(Properties props)
{
String name, value;
StringBuffer buff = new StringBuffer();
Enumeration names = props.propertyNames();
while (names.hasMoreElements())
{
name = (String)names.nextElement();
value = props.getProperty(name);
buff.append(URLEncoder.encode(name) + "=" + URLEncoder.encode(value));
if (names.hasMoreElements()) buff.append("&");
}
return buff.toString();
}
You can add this to your taglib and call this static method from your
servlets.
Hope this helps,
Mike
Alex Kachanov wrote:
> hello, guys!
>
> I'm finishing a small taglib and what to add a finishing touch.
> Inside the tag hadler I wish to encodeURL a string (which is
> a url constructed on the fly).
>
> I'm really lost: how should I do this?
> could you give me two lines of code?
>
> I know how to do this in usual Servlet where response object is
> available.
>
> But how to do this in tag handler?
>
> with best wishes
> Alexander Kachanov
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html