大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> JSP专区 -> JSP中的TagLib应用(4-1)

JSP中的TagLib应用(4-1)

时间: 2021-07-31 作者:daque

底下到了要害局部乐。 对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中设置了少许接口.

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.