stockpricehandler.java
来自「J2EE开发与Weblogic一书中的源代码」· Java 代码 · 共 55 行
JAVA
55 行
package com.learnweblogic.examples.ch4;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class StockPriceHandler extends TagSupport {
private String myTickerSymbol;
private String price = "25 cents";
public String getTickerSymbol() {
return myTickerSymbol;
}
public void setTickerSymbol(String ts) {
myTickerSymbol = ts;
}
public int doStartTag() throws JspException {
/*
You could place any work that you want to have done here.
This method returns a status code. There a number of different
options for these codes, which are discussed later in this
section. This one instructs WebLogic not to evaluate any
expressions inside of the body of the tag.
At this point, you would insert code to go out and
get the stock price from your source. Take that value and
put it into a string variable named 'price'.
*/
String stockPrice = price;
try {
JspWriter out = pageContext.getOut();
out.print(myTickerSymbol + ":" + price);
} catch (Exception e) {
e.printStackTrace();
throw new JspException(e.getMessage());
}
return (SKIP_BODY);
}
/*
Called when the container wants to dispose of the current
tag library.
*/
public void release() {
myTickerSymbol = null;
super.release();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?