i get a nullpointer for ‘pageContext’ in:
package taglibs;
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class OldSchool extends TagSupport {
private JspWriter out = pageContext.getOut();
public int doStartTag() throws JspException {
try {
out.println("hello world");
}
catch (IOException e){
throw new JspException(e);
}
return SKIP_BODY;
}
}
i had no problem doing so in the old syntax but xml-style seams not to work.
i am not sure if line 4 is correct in the .tdl:
<?xml version="1.0" encoding="UTF-8"?>
<taglib 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 http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<description>oldschool test</description>
<tlib-version>1.0</tlib-version>
<short-name>oldschooltest</short-name>
<tag>
<description>test oldschool tags</description>
<name>helloworld</name>
<tag-class>taglibs.OldSchool</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>
for completness the jspx where the tag gets included:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:oldschool="urn:jsptld:/WEB-INF/tlds/oldschool.tld"
xml:lang="en">
<jsp:directive.include file="deploytype.jspx" />
<head></head>
<body>
<oldschool:helloworld />
</body>
</html>