⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stockpricehandler.java

📁 J2EE开发与Weblogic一书中的源代码
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -