• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Tom Barns
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
=============
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

<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
 
Tom Barns
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

<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
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic