您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > JSP >

Jsp tag file例子以及说明(8)

来源:未知 责任编辑:责任编辑 发表时间:2015-03-01 01:35 点击:

  _jspx_th_easy_005fencode_005f0.setInput("<br/> means changing line");//传入参数 
  _jspx_th_easy_005fencode_005f0.doTag();//调用doTag方法 
  _jsp_instancemanager.destroyInstance(_jspx_th_easy_005fencode_005f0); 
  return false; 


例子3 在tag file中引入html和tagf文件
includeDemoTagTest.jsp
[java] 
<%@ taglib prefix="easy" tagdir="/WEB-INF/tags" %> 
<easy:includeDemoTag/> 


includeDemoTag.tag

[java]
This tag file shows the use of the include directive.  
The first include directive demonstrates how you can include 
a static resource called included.html. 
<br/> 
Here is the content of included.html: 
<%@ include file="included.html" %> 
<br/> 
<br/> 
The second include directive includes another dynamic resource: included.tagf. 
<br/> 
<%@ include file="included.tagf" %> 
included.tagf
[java] 
<% 
  out.print("Hello from included.tagf"); 
%> 


included.html

[html]
<table> 
<tr> 
  <td><b>Menu</b></td> 
</tr> 
<tr> 
  <td>CDs</td> 
</tr> 
<tr> 
  <td>DVDs</td> 
</tr> 
<tr> 
  <td>Others</td> 
</tr> 
</table> 


编译后的代码
includeDemoTag_tag.java
[java] 
public void doTag() throws javax.servlet.jsp.JspException, java.io.IOException { 
   javax.servlet.jsp.PageContext _jspx_page_context = (javax.servlet.jsp.PageContext)jspContext; 
   javax.servlet.http.HttpServletRequest request = (javax.servlet.http.HttpServletRequest) _jspx_page_context.getRequest(); 
   javax.servlet.http.HttpServletResponse response = (javax.servlet.http.HttpServletResponse) _jspx_page_context.getResponse(); 
   javax.servlet.http.HttpSession session = _jspx_page_context.getSession(); 
   javax.servlet.ServletContext application = _jspx_page_context.getServletContext(); 
   javax.servlet.ServletConfig config = _jspx_page_context.getServletConfig(); 
   javax.servlet.jsp.JspWriter out = jspContext.getOut(); 
   _jspInit(config); 
   jspContext.getELContext().putContext(javax.servlet.jsp.JspContext.class,jspContext); 
 
   try { 
     out.write("This tag file shows the use of the include directive. \r\n"); 

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • JSP与Servlet
  • 打开一个jsp页面默认查询所有数据,调用action
  • 使用JSP标签库验证用户的输入(2)完
  • 自己动手写MiniBBS系列(基本篇)之用户登录
  • WIN98/2000下的jsp服务器
  • Struts学习傻瓜式入门篇
  • 自定义JSP标签(tag)浅议
  • JSP取当前日期
  • JDBC 入门(一)
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索 - 移动版 - 返回顶部
Copyright © 2008-2013 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1