© 2002 BEA Systems, Inc.


com.bea.p13n.taglib.util
Class UriContentTag

java.lang.Object
  |
  +--javax.servlet.jsp.tagext.TagSupport
        |
        +--javax.servlet.jsp.tagext.BodyTagSupport
              |
              +--com.bea.p13n.taglib.util.UriContentTag

public class UriContentTag
extends javax.servlet.jsp.tagext.BodyTagSupport

Implements the methods necessary to support the uriContent tag.

See Also:
Serialized Form

Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Constructor Summary
UriContentTag()
           
 
Method Summary
 int doAfterBody()
          Pushes output to the JSP page from the buffered BodyContent.
 int doStartTag()
          Evaluates the requested URI and initializes the pageContext scripting variable with the retrieved content.
 java.lang.String getCharset()
          Get the charset.
static java.lang.String getContentType(java.net.URLConnection uc)
          This method uses an existing API call in the document EJB stuff.
 java.lang.String getId()
          Get the id.
 java.lang.String getUri()
          Get the URI.
protected  java.lang.String retrieveURI(java.lang.String aURI)
          Makes an Http connection and fetches the requested URI.
 void setCharset(java.lang.String theCharset)
          Set the charset.
 void setId(java.lang.String theId)
          Set the id.
 void setUri(java.lang.String aUri)
          Set the URI.
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doEndTag, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getParent, getValue, getValues, removeValue, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UriContentTag

public UriContentTag()
Method Detail

setId

public void setId(java.lang.String theId)
Set the id.

Overrides:
setId in class javax.servlet.jsp.tagext.TagSupport

getId

public java.lang.String getId()
Get the id.

Returns:
identifier used for returned value.
Overrides:
getId in class javax.servlet.jsp.tagext.TagSupport

setUri

public void setUri(java.lang.String aUri)
Set the URI.

getUri

public java.lang.String getUri()
Get the URI.

Returns:
URI to be fetched.

setCharset

public void setCharset(java.lang.String theCharset)
Set the charset.

getCharset

public java.lang.String getCharset()
Get the charset.

Returns:
charset of URI to be fetched.

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Evaluates the requested URI and initializes the pageContext scripting variable with the retrieved content.

Returns:
a value telling the JSP engine to evaluate the body of the tag or to skip it if the id tag attribute has not been specified.
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport

doAfterBody

public int doAfterBody()
                throws javax.servlet.jsp.JspException
Pushes output to the JSP page from the buffered BodyContent.

Returns:
a value telling the JSP engine we are done evaluating the body and no more iterations are necessary.
Overrides:
doAfterBody in class javax.servlet.jsp.tagext.BodyTagSupport

retrieveURI

protected java.lang.String retrieveURI(java.lang.String aURI)
                                throws java.io.IOException,
                                       java.net.MalformedURLException
Makes an Http connection and fetches the requested URI. This does a lot of extra work to determine the encoding. First of all it attempts to fetch it from the header and if that doesn't exist, it tries to determine it from the META tags within the HTML from the URL. If that fails, then it uses the default system encoding.

Parameters:
aURI - the URI formatted name of the page to retrieve
Returns:
the page content from the requested URI.

getContentType

public static java.lang.String getContentType(java.net.URLConnection uc)
                                       throws java.io.IOException
This method uses an existing API call in the document EJB stuff. This is a dependency nightmare, but hopefully every webapp that uses this class will include the document.jar file the the root of the EAR.

This is also dependent on the way that the MetaParser determines the encoding of an HTML document. As of 6/21/02 doing 7.0SP1 work, the determineEncoding method returns the charset value embedded in the CONTENT-TYPE attribute of the meta tag. Therefore, no extra string work needs to be done.

The meta tag's normally look like
 META HTTP-EQUIV='...' CONTENT='text/html;charset=jp'
 

This will return 'jp'.

© 2002 BEA Systems, Inc.

Copyright © 2002 BEA Systems, Inc. All Rights Reserved