Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes jsp custom tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp custom tags" Watch "jsp custom tags" New topic
Author

jsp custom tags

namrata jain
Greenhorn

Joined: May 06, 2014
Posts: 3

Java class:DemoCustomTag .java



tdl file:DemoCustomTdl.tdl


jsp page:democustomtag.jsp



when i run this program in netbeans it fire the exceptions
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 10; The processing instruction target matching "[xX][mM][lL]" is not allowed.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1388)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPIData(XMLScanner.java:675)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanPIData(XMLDocumentFragmentScannerImpl.java:1024)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPI(XMLScanner.java:643)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:912)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:846)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:775)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:242)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:345)
at org.apache.jasper.xmlparser.ParserUtils.parseXMLDocument(ParserUtils.java:225)
at org.apache.jasper.xmlparser.ParserUtils.parseXMLDocument(ParserUtils.java:291)
at org.apache.jasper.compiler.TldLocationsCache.getUriFromTld(TldLocationsCache.java:562)
at org.apache.jasper.compiler.TldLocationsCache.processTldsInFileSystem(TldLocationsCache.java:527)
at org.apache.jasper.compiler.TldLocationsCache.processTldsInFileSystem(TldLocationsCache.java:512)
at org.apache.jasper.compiler.TldLocationsCache.init(TldLocationsCache.java:321)
at org.apache.jasper.compiler.TldLocationsCache.getLocation(TldLocationsCache.java:272)
at org.apache.jasper.JspCompilationContext.getTldLocation(JspCompilationContext.java:556)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:480)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:562)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1626)
at org.apache.jasper.compiler.Parser.parse(Parser.java:165)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:223)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:124)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:184)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:409)
at org.apache.jasper.JspC.processFile(JspC.java:1150)
at org.apache.jasper.JspC.execute(JspC.java:1319)
at org.netbeans.modules.web.project.ant.JspC.main(JspC.java:97)
at org.netbeans.modules.web.project.ant.JspCSingle.main(JspCSingle.java:125)
org.apache.jasper.JasperException: PWC6180: Unable to initialize TldLocationsCache
D:\My_Workspace\webappdemo\nbproject\build-impl.xml:573: Java returned: 1
BUILD FAILED (total time: 1 second)



even though i can include the jar file of jstl

any help would be highly appriciated....
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2242
    
    7

In your JSP taglib declaration, the URI should start with a "/"



Everything else seems fine. If your java class is in a package, make sure the tld file <tag-class> is fully qualified name. And may want to add @Override annotation for the doStartTag() method.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60781
    
  65

K. Tsang wrote:In your JSP taglib declaration, the URI should start with a "/"

Not correct. The URI as defined in the tag lib is:
The tag lib declaration in the JSP must match that; not some file path.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60781
    
  65

P.S. This has nothing at all to so with the JSTL, so I don;t know why that was even brought up.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2242
    
    7

Bear Bibeault wrote:The URI as defined in the tag lib is:
The tag lib declaration in the JSP must match that; not some file path.


Oh yes I saw that but forgot to mention it. Thanks for reminding.

namrata jain
Greenhorn

Joined: May 06, 2014
Posts: 3
sir as you said i am incliding "/" before WEB-INF then to same exception cause after compilation then what to do
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9937
    
159

1) The tld file should be named with a .tld extension
2) Make sure your .tld file doesn't have any space or newline or other such characters before the <?xml version="1.0" encoding="ISO-8859-1" ?> content

[My Blog] [JavaRanch Journal]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jsp custom tags
 
Similar Threads
How I can use useUnicode=true&characterEncoding=UTF-8 parameters with JPA connection?
SAXException: Invalid byte 2 of 2-byte UTF-8 sequence
SAXException while generating stubs for a WSDL
How to modify how JUnit is outputting its results?
jsp tag libraries problem