je veux travailler un peux avec les taglib j'ai tester l'exemple du site
ma classe
mon fichier *.tld
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import javax.servlet.jsp.tagext.*; import javax.servlet.jsp.tagext.TagSupport.*; import javax.servlet.jsp.JspWriter.*; import java.io.*; public class HelloTag extends TagSupport { public int doStartTag() {//throws JspException { try { pageContext.getOut().println ("Hello World !"); } catch (IOException e) { // throw new JspException ("I/O Error", e); } return SKIP_BODY; } }
ma page jsp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> <taglib> <tlibversion>1.0</tlibversion> <jspversion>1.1</jspversion> <shortname>name</shortname> <uri></uri> <info>Description de la taglib</info> <tag> <name>hello</name> <tagclass>HelloTag</tagclass> <bodycontent>empty</bodycontent> </tag> </taglib>
mais ca marche pas qulq'un peu m'expliquer
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import=" java.sql.Connection"%> <%@ page import=" java.sql.DriverManager"%> <%@ page import ="java.sql.ResultSet"%> <%@ page import=" java.sql.Statement"%> <%@ page import ="java.sql.*" %> <%@ taglib uri="/WEB-INF/taglib.tld" prefix="t" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> < t:hello /> </body> </html>
Partager