on 06-14-2008 7:08 PM
Hi all
I created a web module project and add a JSP file u201CcustomTagWelcome.jspu201D and a TLD file u201Cadvjhtp1-taglib.tldu201D to the webContent directory. I added also a tag handler
u201CWelcomeTagHandleru201D.
The jsp code:
<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Fig. 10.30: customTagWelcome.jsp -->
<!-- JSP that uses a custom tag to output content. -->
<%-- taglib directive --%>
<%@ taglib uri = "advjhtp1-taglib.tld" prefix = "advjhtp1" %>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Simple Custom Tag Example</title>
</head>
<body>
<p>The following text demonstrates a custom tag:</p>
<h1>
<advjhtp1:welcome />
</h1>
</body>
</html>
The tld content:
<?xml version = "1.0"?>
<!DOCTYPE taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<!-- a tag library descriptor -->
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>advjhtp1</shortname>
<info>
A simple tab library for the examples
</info>
<!-- A simple tag that outputs content -->
<tag>
<name>welcome</name>
<tagclass>
com.deitel.advjhtp1.jsp.taglibrary.WelcomeTagHandler
</tagclass>
<bodycontent>empty</bodycontent>
<info>
Inserts content welcoming user to tag libraries
</info>
</tag>
<!-- A tag with an attribute -->
<tag>
<name>welcome2</name>
<tagclass>
com.deitel.advjhtp1.jsp.taglibrary.Welcome2TagHandler
</tagclass>
<bodycontent>empty</bodycontent>
<info>
Inserts content welcoming user to tag libraries. Uses
attribute "name" to insert the user's name.
</info>
<attribute>
<name>firstName</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- A tag that iterates over an ArrayList of GuestBean -->
<!-- objects, so they can be output in a JSP -->
<tag>
<name>guestlist</name>
<tagclass>
com.deitel.advjhtp1.jsp.taglibrary.GuestBookTag
</tagclass>
<teiclass>
com.deitel.advjhtp1.jsp.taglibrary.GuestBookTagExtraInfo
</teiclass>
<bodycontent>JSP</bodycontent>
<info>
Iterates over a list of GuestBean objects
</info>
</tag>
</taglib>
In the u201Cothersu201D tab of web.xml I choose the tag-libs and for Taglib Location I choose the advjhtp1-taglib.tld. The Taglib Location is advjhtp1-taglib.tld. I added u201Cadvjhtp1-taglib.tldu201D as URI .
When I run the jsp in browser
http://devsrv:50000/servlet_jsp/customTagWelcome.jsp
I get the following exception:
#1.5 #0019DB661008005B0000008A000013B000044FA2C2FDE9C9#1213460381553#com.sap.engine.services.servlets_jsp.server.jsp.JSPParser#sap.com/servlet_jsp_test#com.sap.engine.services.servlets_jsp.server.jsp.JSPParser#Guest#0####b16b6e103a2d11ddb85a0019db661008#SAPEngine_Application_Thread[impl:3]_20##0#0#Error#1#/System/Server#Plain###application [servlet_jsp] Runtime error in compiling of the JSP file <C:/usr/sap/EP7/JC00/j2ee/cluster/server0/apps/sap.com/servlet_jsp_test/servlet_jsp/servlet_jsp/root/customTagWelcome.jsp> !
The error is: com.sap.engine.services.servlets_jsp.lib.jspparser.exceptions.JspParseException: Tag library descriptor cannot be found for uri:]. Exception id: [0019DB661008005B00000088000013B000044FA2C2FDE89A]# #1.5 #0019DB661008005B0000008B000013B000044FA2C2FDEBF1#1213460381553#com.sap.engine.services.servlets_jsp.client.RequestInfoServer#sap.com/servlet_jsp_test#com.sap.engine.services.servlets_jsp.client.RequestInfoServer#Guest#0####b16b6e103a2d11ddb85a0019db661008#SAPEngine_Application_Thread[impl:3]_20##0#0#Error##Plain###application [servlet_jsp] Processing HTTP request to servlet [jsp] finished with error. The error is: com.sap.engine.services.servlets_jsp.server.exceptions.WebIOException: Internal error while parsing JSP page [C:/usr/sap/EP7/JC00/j2ee/cluster/server0/apps/sap.com/servlet_jsp_test/servlet_jsp/servlet_jsp/root/customTagWelcome.jsp]. at com.sap.engine.services.servlets_jsp.server.jsp.JSPParser.parse(JSPParser.java:118) at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.getClassName(JSPServlet.java:238) at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.compileAndGetClassName(JSPServlet.java:429) at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:169) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401) at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266) at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387) at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365) at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944) at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266) at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95) at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Caused by: com.sap.engine.services.servlets_jsp.lib.jspparser.exceptions.JspParseException: Tag library descriptor cannot be found for uri:].
at com.sap.engine.services.servlets_jsp.lib.jspparser.syntax.JspTaglibDirective.verifyAttributes(JspTaglibDirective.java:146)
at com.sap.engine.services.servlets_jsp.lib.jspparser.syntax.JspDirective.parse0(JspDirective.java:141)
at com.sap.engine.services.servlets_jsp.lib.jspparser.syntax.JspDirective.parse(JspDirective.java:102)
at com.sap.engine.services.servlets_jsp.lib.jspparser.syntax.ElementCollection.parse(ElementCollection.java:89)
at com.sap.engine.services.servlets_jsp.lib.jspparser.syntax.ParserImpl.parse(ParserImpl.java:536)
at com.sap.engine.services.servlets_jsp.server.jsp.JSPParser.initParser(JSPParser.java:340)
at com.sap.engine.services.servlets_jsp.server.jsp.JSPParser.parse(JSPParser.java:106)
... 18 more
What is wrong with URI?
Thanks in advance
Yoel
Hi,
You need to add an entry for the <taglib-location> and <taglib-uri>
in the web.xml for using a tld in the project.
And then need to use the same url name in the jsp.
You can go through the following link for the details about web.xml:
http://edocs.bea.com/wls/docs61/webapp/web_xml.html#1017621
Thanks
Ritushree
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
did you try the SAP docs on this?
[Developing Custom JSP Tag Libraries|http://help.sap.com/saphelp_nw70/helpdata/EN/dd/9a7005444a2d478edcc986ef10dd52/frameset.htm]
Did that work?
Regards,
Benny
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
72 | |
26 | |
10 | |
9 | |
7 | |
6 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.