File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes XML parsing error on file /WEB-INF/tlds/diagnostics.tld Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "XML parsing error on file /WEB-INF/tlds/diagnostics.tld" Watch "XML parsing error on file /WEB-INF/tlds/diagnostics.tld" New topic
Author

XML parsing error on file /WEB-INF/tlds/diagnostics.tld

Tom Barns
Ranch Hand

Joined: Oct 27, 2000
Posts: 138
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");

JspWriter out = pageContext.getOut();
out.print(webserver);
}
catch(Exception e)
{
System.out.println(e.getMessage());
System.out.println("Errorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr");

}
return SKIP_BODY;
}
}
==============
shwServer.jsp
===============
<%@ taglib prefix="diag" uri="/WEB-INF/tlds/diagnostics.tld" %>
<html>
<body>
the web server is <dia:getWebServer />

</body>
</html>
=============

Thanks for your help.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

<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

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Tom Barns
Ranch Hand

Joined: Oct 27, 2000
Posts: 138
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

<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
chanoch wiggers
Author
Ranch Hand

Joined: May 24, 2001
Posts: 245
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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML parsing error on file /WEB-INF/tlds/diagnostics.tld