You must use the attribute directive in your Header.tag file as show below -
<body>
<%@ attribute name="subTitle" required="true" rtexprvalue="true" %>
<img src="../images/java_logo.gif"><br>
<em><strong> ${subTitle} </strong></em> <br>
</body>
Pregunta
My project in eclipse -
I get the error below when I run MyTagUser.jsp - HTTP Status 500 - /jsp/MyTagUser.jsp(14,0) Attribute subTitle invalid for tag Header according to TLD
org.apache.jasper.JasperException: /jsp/MyTagUser.jsp(14,0) Attribute subTitle
invalid for tag Header according to TLD
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)...etc.
Snippet from Header.jsp -
<body>
<img src="../images/java_logo.gif"><br>
<em><strong> ${subTitle} </strong></em> <br>
</body>
Snippet from MyTagUser.jsp -
<%@ taglib prefix="myTags" tagdir="/WEB-INF/tags"%>
<html>
<head>
</head>
<body>
<myTags:Header subTitle="Java is the best !!!" />
JSP and Servlets.
</body>
</html>
Solución
You must use the attribute directive in your Header.tag file as show below -
<body>
<%@ attribute name="subTitle" required="true" rtexprvalue="true" %>
<img src="../images/java_logo.gif"><br>
<em><strong> ${subTitle} </strong></em> <br>
</body>
Otros consejos
First Solution:
It seems, you wanted to include header area in your jsp. But it's wrong way.
You should create a header.jsp and then include header.jsp into your MyTagUser.jsp and they should be under the WEB-INF directory(or its sub-directory).
Including method : <%@ include file="WEB-INF/tags/header.jsp"> use this code in MyTagUser.jsp
Second Solution :
in your tag file
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> core jstl taglib if necessary
<%@ attribute name="subtitle" required="true" %> this is subTitle attribute
you should define attribute(s). check out http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPTags5.html