选择显示字体大小

jsp中的taglib应用(4)

下面到了关键部分乐。 对tag进行处理。其实很多情况下我们是使用已经提供的taglib.

别人/公司已经做好了tag和处理部分,打好了包 我们需要做的只是在我们的jsp中去应用.

但是当我们自己做个taglib时, 就需要编写这部分tag handler了.

这里只针对上面文件里提到的insert tag,其他的为了避免重复,就不一一说明了

==================== inserttag.java==============================

/*

* $id: inserttag.java,v 1.13 2000/03/04 02:54:57 brydon exp $

* copyright 1999 sun microsystems, inc. all rights reserved.

* copyright 1999 sun microsystems, inc. tous droits réservés.

*/

package com.sun.estore.taglib;

import javax.servlet.jsp.jsptagexception;

import javax.servlet.jsp.tagext.tagsupport;

import com.sun.estore.util.debug;

/**

* this class is an easy interface to the jsp template or other

* text that needs to be inserted.

* @author greg murray

*/

public class inserttag extends tagsupport {

private boolean directinclude = false;

private string parameter = null;

private string templatename = null;

private template template = null;

private templateparameter templateparam = null;

/**

* default constructor

*/

public inserttag() {

super();

}

public void settemplate(string templatename){

this.templatename = templatename;

}

public void setparameter(string parameter){

this.parameter = parameter;

}

public int dostarttag() {

try{

if (templatename != null){

template = (template)pagecontext.getrequest().getattribute("template");

}

} catch (nullpointerexception e){

debug.println("error extracting template from session: " + e);

}

if (parameter != null && template != null) templateparam = (templateparameter)template.getparam(parameter);

if (templateparam != null) directinclude = templateparam.isdirect();

return skip_body;

}

public int doendtag() throws jsptagexception {

try{

pagecontext.getout().flush();

} catch (exception e){

// do nothing

}

try {

if (directinclude && templateparam != null) {

pagecontext.getout().println(templateparam.getvalue());

} else if (templateparam != null) {

if (templateparam.getvalue() != null) pagecontext.getrequest().getrequestdispatcher(templateparam.getvalue()).include(pagecontext.getrequest(), pagecontext.getresponse());

}

} catch (throwable ex) {

ex.printstacktrace();

}

return eval_page;

}

}

可以看到。inserttag.java继承了javax.servlet.jsp.tagext.tagsupport类. 因为在tagsupport中定义了一些接口.


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons