background image

Parameters for the URL

<< Screen Definitions | Scripting in JSP Pages >>
<< Screen Definitions | Scripting in JSP Pages >>

Parameters for the URL

TABLE 8­16
Parameters for the URL /bookstore
Parameter Name
Parameter Value
isDirect
title
Duke
's Bookstore
true
banner
/banner.jsp
false
body
/bookstore.jsp
false
tut-install/javaeetutorial5/examples/web/bookstore3/src/java/com/sun/bookstore3/template/InsertTag.java
inserts parameters of the screen definition into the response. The doTag method retrieves the
definition object from the page context and then inserts the parameter value. If the parameter is
direct, it is directly inserted into the response; otherwise, the request is sent to the parameter,
and the response is dynamically included into the overall response.
public void doTag() throws JspTagException {
Definition definition = null;
Parameter parameter = null;
boolean directInclude = false;
PageContext context = (PageContext)getJspContext();
// get the definition from the page context
definition = (Definition)context.getAttribute(
definitionName, context.APPLICATION_SCOPE);
// get the parameter
if (parameterName != null && definition != null)
parameter = (Parameter)
definition.getParam(parameterName);
if (parameter != null)
directInclude = parameter.isDirect();
try {
// if parameter is direct, print to out
if (directInclude && parameter
!= null)
context.getOut().print(parameter.getValue());
// if parameter is indirect,
include results of dispatching to page
else {
if ((parameter != null) &&
(parameter.getValue() !=
null))
context.include(parameter.getValue());
}
} catch (Exception ex) {
throw new JspTagException(ex.getMessage());
}
}
Programming Simple Tag Handlers
The Java EE 5 Tutorial · September 2007
272