Hi All I'm trying to run very sinple example for taglib and i'm getting this error: " A Servlet Exception Has Occurred org.apache.jasper.JasperException: XML parsing error on file /WEB-INF/tlds/diagnostics.tld: (line 2, col -1): Element type "taglib" is not declared. " Here is all the files that i'm using. diagonestics.tld ================== <?xml version="1.0" ?> <taglib> <tlibversion>1.0</tlibversion> <jspversion>1.1</jspversion> <shortname>diag</shortname> <tag> <name>getWebServer</name> <tagclass>GetWebServerTag</tagclass> <bodycontent>empty<bodycontent> </tag> </taglib> ================= GetWebServerTag.java =============== import javax.servlet.http.*; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; import java.net.*; public class GetWebServerTag extends TagSupport {
public int doStartTag() throws JspException { try {
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); URL url = new URL("http",request.getServerName(),request.getServerPort(),"/"); URLConnection con =url.openConnection(); ((HttpURLConnection) con).setRequestMethod("OPTIONS"); String webserver = con.getHeaderField("server");
<bodycontent>empty<bodycontent> Shouldn't this be <bodycontent>empty</bodycontent> Also, in your JSP: the web server is <dia:getWebServer /> Shouldn't this be the web server is <diag:getWebServer /> Afterall, your prefix is diag regds. - satya
Thanks a lot. It was a good catch,but I'm still getting same error. as in the first post. any clue please?
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
posted
0
<bodycontent>empty</bodycontent> Right now I don't have any books with me (I am sort of on vacation, din't expect to be connected to the web... ) You might want to check if you empty is valid or maybe you should use EMPTY. Somehow I beleive its the latter one you should use... regds. - satya
I've corrected it, this should work ok for pure XML ness. If it still doesnt work then you may need to check the docs because there will be missing element somewhere: <?xml version="1.0" ?> <taglib> <tlibversion>1.0</tlibversion> <jspversion>1.1</jspversion> <shortname>diag</shortname> <tag> <name>getWebServer</name> <tagclass>GetWebServerTag</tagclass> <bodycontent>empty</bodycontent> </tag> </taglib>
chanoch<p><a href="http://www.amazon.com/exec/obidos/ASIN/1861007736/" target="_blank" rel="nofollow">Author of Professional Apache Tomcat</a></p>