Custom tag handler not working in tomcat 7, but working ok in tomcat 6
i encountered very strange problem with my custom jsp tag - what was working ok when deployed in tomcat 6 is not working in tomcat 7 environment. here is my tag handler class:
private Long millis;
/**
* Constructor
*/
public ConvertMillisecondsValueTag() {
super();
millis = null;
}
/**
* Tag name
*/
public String getTagName() {
return "convertMillisValueTag";
}
public Long getMillis() {
return this.millis;
}
public void setMillis(Long millis) {
this.millis = millis;
}
/**
* EVAL_PAGE
*/
public int doEndTag() throws JspTagException {
StringBuilder buff = new StringBuilder();
long timeInSeconds = this.millis/1000;
int seconds = (int)(timeInSeconds % 60);
int minutes = (int)((timeInSeconds % 3600) / 60);
int hours = (int)((timeInSeconds % 86400) / 3600);
int days = (int)((timeInSeconds / 86400));
if (days > 0) {
buff.append(days + " d, ");
}
if (hours > 0) {
buff.append(hours + " h, ");
}
if (minutes > 0) {
buff.append(minutes + " min, ");
}
if (seconds > 0) {
buff.append(seconds + " sec");
}
try {
pageContext.getOut().print(buff.toString());
} catch (Exception e) {
e.printStackTrace();
}
return TagSupport.EVAL_PAGE;
}
/**
* Release this instance of tag
*/
public void release() {
this.millis = null;
}
and here my tld definition:
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0">
<description>Itedge JSP Tag Library</description>
<tlib-version>1.0</tlib-version>
<short-name>itedge</short-name>
<uri>http://www.itedge.sk/tags</uri>
<tag>
<description>
Takes milliseconds input (long) and displays it in
second, minutes, hours and days
</description>
<name>convertMillisValue</name>
<tag-class>com.itedge.solutionmanager.web.tags.ConvertMillisecondsValueTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<description>Milliseconds input (long).</description>
<name>millis</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
Here is the use of the tag:
When i deploy the project in tomcat 6, it's working fine, converting milliseconds value and displaying it, but in tomcat 7, it simple doesn't print nothing, and when i set breakpoint in doEndTag meth开发者_StackOverflow中文版od in debug mode, there is no breakpoint match. Do you have any idea, what could be wrong ? I know that tomcat 6 uses servlet 2.5 api and tomcat 7 uses 3.0 servlet api, that's the only clue i have.
probably:
<%@ taglib prefix="itedge" uri="http://www.itedge.sk/tags" %>
You will need to replace it:
<%@ taglib prefix="itedge" uri="/WEB-INF/tlds/yourFilename.tld" %>
精彩评论