aspose file tools*
The moose likes JSP and the fly likes Taglib Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Taglib" Watch "Taglib" New topic
Author

Taglib

francis varkey
Ranch Hand

Joined: Sep 13, 2005
Posts: 169
Respected Sirs,

When running jsp program that uses taglibs I got the error message,

*******************


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to initialize TldLocationsCache: XML parsing error on file /WEB-INF/tlds/diagnostics.tld
org.apache.jasper.compiler.TldLocationsCache.init(TldLocationsCache.java:249)
org.apache.jasper.compiler.TldLocationsCache.getLocation(TldLocationsCache.java:220)
org.apache.jasper.JspCompilationContext.getTldLocation(JspCompilationContext.java:475)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:417)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:483)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1539)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:220)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

***************************************

My files are

1) diagnostics.tld
**************
<?xml version="1.0"?>
<!DOCTYPE taglib PUBLIC
"-//Sun Microsystems,Inc.//DTD JSP Tag Library 1.2EN//"
"http://java.sun.com/dtd/web_jsptaglibrary-1.2.dtd">

<taglib xmlns="http://java.sun.com/JSP/TagLibraryDescriptor">
<tlib-version>1.0</tlib-version>
<jsp-version>1.5</jsp-version>
<short-name>diag</short_name>

<tag>
<name>getWebServer</name>
<tag-class> pack.GetWebServerTag </tag-class>
<body-content>empty</body-content>
</tag>
</taglib>

********************************
2)GetWebServerTag.java

package pack;
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 req=(HttpServletRequest)pageContext.getRequest();
String host=req.getServerName();
int port=req.getServerPort();
URL url=new URL("http",host,port,"/");
HttpURLConnection con=(HttpURLConnection)url.openConnection();
con.setRequestMethod("OPTIONS");
String webserver=con.getHeaderField("server");
JspWriter out=pageContext.getOut();
out.print(webserver);
}
catch(IOException e)
{
throw new JspException(e.getMessage());
}
return SKIP_BODY;
}


};


*********************
3) ShowWebServer.jsp

<%@ page session="false" %>
<%@ taglib prefix="diag" uri="/WEB-INF/tlds/diagnostics.tld" %>
<html>
<body>
The webserver is<diag:getWebServer/>
</body>
</html>

******************************
4) Entries from web.xml


<web-app>

<taglib>
<taglib-uri>
/WEB-INF/tlds/diagnostics.tld
</taglib-uri>
<taglib-location>
/WEB-INF/tlds/diagnostics.tld
</taglib-location>
</taglib>

</web-app>


**********************

I have taken this example from

The Complete Reference JSP2.0

and I am using tomcat5



Regards Francis
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5
XML-SPY found that you spelled short-name two different ways so the closing tag does not match the opening tag - an XML parsing error.

Bill
francis varkey
Ranch Hand

Joined: Sep 13, 2005
Posts: 169
I have wrote correctly the <short-name>tag.
<short-name>diag</short-name>
But I got the error massage still.

Also got error message when starting the server
*****************

May 17, 2006 12:19:54 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
May 17, 2006 12:19:54 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1047 ms
May 17, 2006 12:19:55 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
May 17, 2006 12:19:55 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.0.28
May 17, 2006 12:19:55 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
May 17, 2006 12:19:55 PM org.apache.catalina.core.StandardHost getDeployer
INFO: Create Host deployer for direct deployment ( non-jmx )
May 17, 2006 12:19:55 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Processing Context configuration file URL file:C:\Program Files\Apache Sof
tware Foundation\Tomcat 5.0\conf\Catalina\localhost\balancer.xml
May 17, 2006 12:19:55 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Processing Context configuration file URL file:C:\Program Files\Apache Sof
tware Foundation\Tomcat 5.0\conf\Catalina\localhost\admin.xml
May 17, 2006 12:19:55 PM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=tru
e
May 17, 2006 12:19:55 PM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNul
l=true
May 17, 2006 12:19:56 PM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.webapp.admin.ApplicationResources', retur
nNull=true
May 17, 2006 12:19:57 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Processing Context configuration file URL file:C:\Program Files\Apache Sof
tware Foundation\Tomcat 5.0\conf\Catalina\localhost\manager.xml
May 17, 2006 12:19:57 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /tomcat-docs from URL file:C:\P
rogram Files\Apache Software Foundation\Tomcat 5.0\webapps\tomcat-docs
May 17, 2006 12:19:57 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /jsp-examples from URL file:C:\
Program Files\Apache Software Foundation\Tomcat 5.0\webapps\jsp-examples
May 17, 2006 12:19:57 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /servlets-examples from URL fil
e:C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\servlets-exampl
es
May 17, 2006 12:19:57 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /webdav from URL file:C:\Progra
m Files\Apache Software Foundation\Tomcat 5.0\webapps\webdav
May 17, 2006 12:19:57 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path from URL file:C:\Program Files
\Apache Software Foundation\Tomcat 5.0\webapps\ROOT
May 17, 2006 12:19:57 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /cms from URL file:C:\Program F
iles\Apache Software Foundation\Tomcat 5.0\webapps\cms
May 17, 2006 12:19:57 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /azad from URL file:C:\Program
Files\Apache Software Foundation\Tomcat 5.0\webapps\azad
May 17, 2006 12:19:58 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /joby from URL file:C:\Program
Files\Apache Software Foundation\Tomcat 5.0\webapps\joby
May 17, 2006 12:19:59 PM org.apache.catalina.core.StandardContext start
SEVERE: Error reading tld listeners javax.servlet.ServletException: Exception pr
ocessing TLD at resource path /WEB-INF/tlds/diagnostics.tld in context /joby
javax.servlet.ServletException: Exception processing TLD at resource path /WEB-I
NF/tlds/diagnostics.tld in context /joby
at org.apache.catalina.startup.TldConfig.tldScanTld(TldConfig.java:549)
at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:301)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
282)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:80
7)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)

at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDep
loyer.java:277)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
ava:701)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:432
)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)

at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478
)
at org.apache.catalina.core.StandardService.start(StandardService.java:4
80)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:231
3)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)
May 17, 2006 12:19:59 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
May 17, 2006 12:19:59 PM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
May 17, 2006 12:19:59 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/47 config=C:\Program Files\Apache Software Foundat
ion\Tomcat 5.0\conf\jk2.properties
May 17, 2006 12:19:59 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4828 ms
Resolve entity failed-//Sun Microsystems,Inc.//DTD JSP Tag Library 1.2EN// http:
//java.sun.com/dtd/web_jsptaglibrary-1.2.dtd
May 17, 2006 12:20:09 PM org.apache.jasper.xmlparser.MyEntityResolver resolveEnt
ity
SEVERE: Invalid PUBLIC ID: -//Sun Microsystems,Inc.//DTD JSP Tag Library 1.2EN//

Regards francis
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5


Looking at the source code, I see that this has to be something about the content of the TLD file diagnostics.tld but it is not clear exactly what.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Taglib