Compoze Software, Inc.

com.compoze.jsp
Class JspUtility

java.lang.Object
  |
  +--com.compoze.jsp.JspUtility

public class JspUtility
extends java.lang.Object

This class contains utility methods that are commonly used from JSP pages.


Constructor Summary
JspUtility()
           
 
Method Summary
static java.lang.String convertNullString(java.lang.String string)
          Converts a null string into an empty string
static java.lang.String escapeAndProcessLinks(java.lang.String sUnprocessed)
          HTML escapes a string and process its links for use in a JSP page.
static java.lang.String escapeAndProcessLinks(java.lang.String sUnprocessed, boolean bNewWindow)
          HTML escapes a string and process its links for use in a JSP page.
static java.lang.String getBlankParameters(javax.servlet.http.HttpServletRequest request, java.lang.String[] parameters, java.lang.String sSeparator)
          Get all specified request parameters that are blank and turn them into a comma separated list.
static java.util.Vector getParameterAsVector(javax.servlet.http.HttpServletRequest request, java.lang.String sParameter, java.lang.String sSeparator)
          Gets a list of the separated values in a parameter.
static java.lang.String htmlEscape(java.lang.Object obj)
          HTML escapes a object for use in a JSP page.
static java.lang.String htmlEscape(java.lang.String sUnescapedString)
          HTML escapes a string for use in a JSP page.
static java.lang.String htmlEscape(java.lang.String sUnescapedString, java.lang.String sEncoding)
          HTML escapes a string for use in a JSP page.
static java.lang.String htmlEscapeUnformatted(java.lang.String sUnescapedString)
          Parially HMTL escapes a string for use in a JSP page.
static java.lang.String htmlEscapeUnformatted(java.lang.String sUnescapedString, java.lang.String[] sTags)
          Partially HTML escapes a string for use in a JSP page.
static void insertURLContents(java.net.URL url, java.io.Writer writer)
          Connects to the given URL and write its contents to the given writer.
static void insertURLContents(java.net.URL url, java.io.Writer writer, boolean bWriteBaseHref)
          Connects to the given URL and write its contents to the given writer.
static void main(java.lang.String[] args)
          Exerciser.
static java.lang.String processLinks(java.lang.String sUnprocessed)
          Processes a string, replacing any apparent URLs with the HTML code needed to generate an HREF link to that URL.
static java.lang.String processLinks(java.lang.String sUnprocessed, boolean bNewWindow)
          Processes a string, replacing any apparent URLs with the HTML code needed to generate an HREF link to that URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JspUtility

public JspUtility()
Method Detail

htmlEscape

public static java.lang.String htmlEscape(java.lang.Object obj)
HTML escapes a object for use in a JSP page. The object to string representation is used. This uses the default Character Encoding of the Virtual Machine
Parameters:
obj - object to escape (may not be wnull)
Returns:
the escaped string

htmlEscape

public static java.lang.String htmlEscape(java.lang.String sUnescapedString)
HTML escapes a string for use in a JSP page. This uses the default Character Encoding of the Virtual Machine
Parameters:
sUnescapedString - string to escape
Returns:
the escaped string

htmlEscape

public static java.lang.String htmlEscape(java.lang.String sUnescapedString,
                                          java.lang.String sEncoding)
                                   throws java.io.UnsupportedEncodingException
HTML escapes a string for use in a JSP page. A Character Encoding is used to determine how the characters are escaped. This should be used if the desired encoding is different than the default.
Parameters:
sUnescapedString - string to escape
sEncoding - character encoding
Returns:
the escaped string

htmlEscapeUnformatted

public static java.lang.String htmlEscapeUnformatted(java.lang.String sUnescapedString)
Parially HMTL escapes a string for use in a JSP page. This method escapes all but the following HTML formatting tags: <br><i><b><u><font> <ol><ul><li><pre><code>.
Parameters:
sUnescapedString - the unescaped string

htmlEscapeUnformatted

public static java.lang.String htmlEscapeUnformatted(java.lang.String sUnescapedString,
                                                     java.lang.String[] sTags)
Partially HTML escapes a string for use in a JSP page.
Parameters:
sUnescapedString - the unescaped string
sTags - the tags that are not to be escaped, as their localized name. For example new String[] { "b", "i", "font" }

processLinks

public static java.lang.String processLinks(java.lang.String sUnprocessed,
                                            boolean bNewWindow)
Processes a string, replacing any apparent URLs with the HTML code needed to generate an HREF link to that URL.
Parameters:
sUnprocessed - the unprocessed string
bNewWindow - if true, link should open new browser window
Returns:
the processed string

processLinks

public static java.lang.String processLinks(java.lang.String sUnprocessed)
Processes a string, replacing any apparent URLs with the HTML code needed to generate an HREF link to that URL. By default, link appears in current browser window.
Parameters:
sUnprocessed - the unprocessed string
Returns:
the processed string

escapeAndProcessLinks

public static java.lang.String escapeAndProcessLinks(java.lang.String sUnprocessed)
HTML escapes a string and process its links for use in a JSP page. By default, link appears in current browser window.
Parameters:
sUnprocessed - the unprocessed string
Returns:
the processed string
See Also:
htmlEscape(String), processLinks(String)

escapeAndProcessLinks

public static java.lang.String escapeAndProcessLinks(java.lang.String sUnprocessed,
                                                     boolean bNewWindow)
HTML escapes a string and process its links for use in a JSP page.
Parameters:
sUnprocessed - the unprocessed string
bNewWindow - if true, link should open new browser window
Returns:
the processed string
See Also:
htmlEscape(String), processLinks(String)

insertURLContents

public static void insertURLContents(java.net.URL url,
                                     java.io.Writer writer)
                              throws java.io.IOException
Connects to the given URL and write its contents to the given writer. Input and output are buffered.
Parameters:
url - URL to connect to
writer - writer to write contents of URL to
Throws:
java.io.IOException - if an I/O error occurred

insertURLContents

public static void insertURLContents(java.net.URL url,
                                     java.io.Writer writer,
                                     boolean bWriteBaseHref)
                              throws java.io.IOException
Connects to the given URL and write its contents to the given writer. Input and output are buffered.
Parameters:
url - URL to connect to
writer - writer to write contents of URL to
bWriteBaseHref - if true, write a base href tag so that relative links work properly
Throws:
java.io.IOException - if an I/O error occurred

getBlankParameters

public static java.lang.String getBlankParameters(javax.servlet.http.HttpServletRequest request,
                                                  java.lang.String[] parameters,
                                                  java.lang.String sSeparator)
Get all specified request parameters that are blank and turn them into a comma separated list. This is useful for form validation.
Parameters:
request - the request
parameters - the parameters to check
sSeparator - the string to separate parameters with
Returns:
the comma separated list of blank parameters, or null if there are none

getParameterAsVector

public static java.util.Vector getParameterAsVector(javax.servlet.http.HttpServletRequest request,
                                                    java.lang.String sParameter,
                                                    java.lang.String sSeparator)
Gets a list of the separated values in a parameter.
Parameters:
request - the request
sParameter - the parameter to get
sSeparator - the separator character
Returns:
the list of values, if none then an empty list is returned

convertNullString

public static java.lang.String convertNullString(java.lang.String string)
Converts a null string into an empty string
Parameters:
string - String to be converted
Returns:
the converted string

main

public static void main(java.lang.String[] args)
Exerciser.
Parameters:
args - the arguments

Compoze Software, Inc.

Copyright ©1999-2003 Compoze Software, Inc. All rights reserved.