10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Programming SimpleTag Handlers<br />

270<br />

public void doTag() throws JspTagException {<br />

Definition definition = null;<br />

Parameter parameter = null;<br />

boolean directInclude = false;<br />

PageContext context = (PageContext)getJspContext();<br />

}<br />

// get the definition from the page context<br />

definition = (Definition)context.getAttribute(<br />

definitionName, context.APPLICATION_SCOPE);<br />

// get the parameter<br />

if (parameterName != null && definition != null)<br />

parameter = (Parameter)<br />

definition.getParam(parameterName);<br />

if (parameter != null)<br />

directInclude = parameter.isDirect();<br />

try {<br />

// if parameter is direct, print to out<br />

if (directInclude && parameter != null)<br />

context.getOut().print(parameter.getValue());<br />

// if parameter is indirect,<br />

include results of dispatching to page<br />

else {<br />

if ((parameter != null) &&<br />

(parameter.getValue() != null))<br />

context.include(parameter.getValue());<br />

}<br />

} catch (Exception ex) {<br />

throw new JspTagException(ex.getMessage());<br />

}<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!