Hay tres ejemplos en esta práctica. Puede comprobar cómo existen al mismo tiempo en una aplicación.
1. Etiqueta de archivo
Header.tag
<%@tag description="put the tag description here" pageEncoding="UTF-8"%>
<%-- The list of normal or fragment attributes can be specified here: --%>
<%@attribute name="fontColor" required="true"%>
<%@tag body-content="tagdependent" %>
<%-- any content can be specified here e.g.: --%>
<em><strong><font color="${fontColor}">
<jsp:doBody/>
</font></strong></em><br>
|
index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="myTags" tagdir="/WEB-INF/tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello< World!</h1>
<myTags:Header fontColor="blue">
Schedule a java task to run at a certain time, and wrap it as a windows service
Written by admin on August 21, 2009 — Leave a Comment [edit]
Make a Java program that run at a certain time is not difficult just use java.util.Timer and java.util.TimerTask classes, here is the code.
</myTags:Header>
</body>
</html>
|
¡Hola
< myTags: Header fontColor = "blue"> Programe una tarea de Java para que se ejecute en un momento determinado y envuélvala como un servicio de Windows Escrito por el administrador el 21 de agosto de 2009 – Deja un comentario [edit]
Hacer un programa Java que se ejecute en un momento determinado no es difícil solo usa las clases java.util.Timer y java.util.TimerTask, aquí está el código. myTags: Header>
< myTags: Header fontColor = "blue"> Programe una tarea de Java para que se ejecute en un momento determinado y envuélvala como un servicio de Windows Escrito por el administrador el 21 de agosto de 2009 – Deja un comentario [edit]
Hacer un programa Java que se ejecute en un momento determinado no es difícil solo usa las clases java.util.Timer y java.util.TimerTask, aquí está el código. myTags: Header>
2. Manejador de etiquetas simple
TestSimpleTag.java
package test; import java.io.IOException; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.SimpleTagSupport; public class TestSimpleTag extends SimpleTagSupport{ public void doTag() throws JspException, IOException{ getJspContext().getOut().print("This is testing of a simple custom tag"); } } |
test.tld
<?xml version="1.0" encoding="UTF-8"?> <taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"> <tlib-version>1.0</tlib-version> <short-name>test</short-name> <uri>simpleTags</uri> <tag> <name>simpleOne</name> <tag-class>test.TestSimpleTag</tag-class> <body-content>empty</body-content> </tag> </taglib> |
index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="myTags" tagdir="/WEB-INF/tags" %>
<%@taglib prefix="testTags" uri="simpleTags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello< World!</h1>
<myTags:Header fontColor="blue">
Schedule a java task to run at a certain time, and wrap it as a windows service
Written by admin on August 21, 2009 — Leave a Comment [edit]
Make a Java program that run at a certain time is not difficult just use java.util.Timer and java.util.TimerTask classes, here is the code.
</myTags:Header>
<testTags:simpleOne/>
</body>
</html>
|
Hello
Programe una tarea de Java para que se ejecute en un momento determinado y envuélvala como un servicio de Windows Escrito por el administrador el 21 de agosto 2009 – Deja un comentario [edit]
Hacer un programa Java que se ejecute en un momento determinado no es difícil solo usa las clases java.util.Timer y java.util.TimerTask, aquí está el código. myTags: Header>
Hacer un programa Java que se ejecute en un momento determinado no es difícil solo usa las clases java.util.Timer y java.util.TimerTask, aquí está el código. myTags: Header>
3. Controlador de etiquetas clásico
TestClassicTag.java
package test; import java.io.IOException; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.TagSupport; public class TestClassicTag extends TagSupport{ @Override public int doStartTag() throws JspException{ JspWriter out = pageContext.getOut(); try{ out.println("classic tag output"); }catch(IOException e){ throw new JspException("IOException- " + e.toString()); } return SKIP_BODY; } } |
test.tld
<?xml version="1.0" encoding="UTF-8"?> <taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"> <tlib-version>1.0</tlib-version> <short-name>test</short-name> <uri>simpleTags</uri> <tag> <name>simpleOne</name> <tag-class>test.TestSimpleTag</tag-class> <body-content>empty</body-content> </tag> <tag> <name>classicOne</name> <tag-class>test.TestClassicTag</tag-class> <body-content>empty</body-content> </tag> </taglib> |
index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="myTags" tagdir="/WEB-INF/tags" %>
<%@taglib prefix="testTags" uri="simpleTags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello< World!</h1>
<myTags:Header fontColor="blue">
Schedule a java task to run at a certain time, and wrap it as a windows service
Written by admin on August 21, 2009 — Leave a Comment [edit]
Make a Java program that run at a certain time is not difficult just use java.util.Timer and java.util.TimerTask classes, here is the code.
</myTags:Header>
<testTags:simpleOne/>
<br>
<testTags:classicOne/>
</body>
</html>
|
Hello
Programe una tarea de Java para que se ejecute en un momento determinado y envuélvala como un servicio de Windows Escrito por el administrador el 21 de agosto 2009 – Deja un comentario [edit]
Hacer un programa Java que se ejecute en un momento determinado no es difícil solo usa las clases java.util.Timer y java.util.TimerTask, aquí está el código. myTags: Header>
Hacer un programa Java que se ejecute en un momento determinado no es difícil solo usa las clases java.util.Timer y java.util.TimerTask, aquí está el código. myTags: Header>