29.01.2013 Views

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

This variable will store the name attribute of the tag<br />

private java.lang.String name;<br />

/**<br />

* HelloTag default constructor.<br />

*/<br />

public HelloTag() {<br />

super();<br />

}<br />

/**<br />

* Called when the end of the tag is reached. Here we simply<br />

* call our bean to get our output and then write it out.<br />

*<br />

* Note that we have access to the pageContext implicit object.<br />

*<br />

* At the end of the method we return an integer that tells the<br />

* Web container whether the rest of the JSP page should be<br />

* executed. If set to SKIP_PAGE then the JSP execution will<br />

* stop. If set to EVAL_PAGE, execution will continue.<br />

*<br />

* @return indication to continue page execution<br />

* @exception javax.servlet.jsp.JspException<br />

*/<br />

public int doEndTag() throws JspException {<br />

}<br />

int result = EVAL_PAGE;<br />

// Here we call our bean to get our message<br />

HelloBean hb = new HelloBean();<br />

String mess = hb.hello(name);<br />

try {<br />

// and here we write the message back out<br />

pageContext.getOut().write(mess);<br />

} catch (IOException e) {<br />

// whoops<br />

e.printStackTrace();<br />

}<br />

release();<br />

return result;<br />

... as our tag is a bean, we also provide accessor and setter methods<br />

}<br />

282 <strong>IBM</strong> <strong>WebSphere</strong> <strong>Application</strong> <strong>Server</strong> - Express V5.0.2 Developer Handbook

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

Saved successfully!

Ooh no, something went wrong!