javax.servlet.jsp.tagext.TagFileInfo Java Examples
The following examples show how to use
javax.servlet.jsp.tagext.TagFileInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TagFileProcessor.java From packagedrone with Eclipse Public License 1.0 | 6 votes |
public void visit(Node.CustomTag n) throws JasperException { TagFileInfo tagFileInfo = n.getTagFileInfo(); if (tagFileInfo != null) { String tagFilePath = tagFileInfo.getPath(); if (tagFilePath.startsWith("/META-INF/")) { // For tags in JARs, add the TLD and the tag as a dependency String[] location = compiler.getCompilationContext().getTldLocation( tagFileInfo.getTagInfo().getTagLibrary().getURI()); // Add TLD pageInfo.addDependant("jar:" + location[0] + "!/" + location[1]); // Add Tag pageInfo.addDependant("jar:" + location[0] + "!" + tagFilePath); } else { pageInfo.addDependant(tagFilePath); } Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(), pageInfo); n.setTagHandlerClass(c); } visitBody(n); }
Example #2
Source File: Node.java From Tomcat8-Source-Read with MIT License | 6 votes |
public CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, TagFileInfo tagFileInfo) { super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); this.uri = uri; this.prefix = prefix; this.tagFileInfo = tagFileInfo; this.tagInfo = tagFileInfo.getTagInfo(); this.customNestingLevel = makeCustomNestingLevel(); this.childInfo = new ChildInfo(); this.implementsIterationTag = false; this.implementsBodyTag = false; this.implementsTryCatchFinally = false; this.implementsSimpleTag = true; this.implementsJspIdConsumer = false; this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes(); }
Example #3
Source File: Node.java From packagedrone with Eclipse Public License 1.0 | 6 votes |
public CustomTag(String jspVersion, String qName, String prefix, String localName, String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, TagFileInfo tagFileInfo) { super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); this.jspVersion = Double.valueOf(jspVersion).doubleValue(); this.uri = uri; this.prefix = prefix; this.tagFileInfo = tagFileInfo; this.tagInfo = tagFileInfo.getTagInfo(); this.customNestingLevel = makeCustomNestingLevel(); this.childInfo = new ChildInfo(); this.implementsIterationTag = false; this.implementsBodyTag = false; this.implementsTryCatchFinally = false; this.implementsSimpleTag = true; this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes(); }
Example #4
Source File: TagLibraryInfoImpl.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public String toString() { StringWriter sw = new StringWriter(); PrintWriter out = new PrintWriter(sw); print("tlibversion", tlibversion, out); print("jspversion", jspversion, out); print("shortname", shortname, out); print("urn", urn, out); print("info", info, out); print("uri", uri, out); print("tagLibraryValidator", "" + tagLibraryValidator, out); for (TagInfo tag : tags) { out.println(tag.toString()); } for (TagFileInfo tagFile : tagFiles) { out.println(tagFile.toString()); } for (FunctionInfo function : functions) { out.println(function.toString()); } return sw.toString(); }
Example #5
Source File: TagLibraryInfoImpl.java From Tomcat8-Source-Read with MIT License | 6 votes |
private TagFileInfo createTagFileInfo(TagFileXml tagFileXml, Jar jar) throws JasperException { String name = tagFileXml.getName(); String path = tagFileXml.getPath(); if (path == null) { // path is required err.jspError("jsp.error.tagfile.missingPath"); } else if (!path.startsWith("/META-INF/tags") && !path.startsWith("/WEB-INF/tags")) { err.jspError("jsp.error.tagfile.illegalPath", path); } TagInfo tagInfo = TagFileProcessor.parseTagFileDirectives(parserController, name, path, jar, this); return new TagFileInfo(name, path, tagInfo); }
Example #6
Source File: Node.java From tomcatsrc with Apache License 2.0 | 6 votes |
public CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, TagFileInfo tagFileInfo) { super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); this.uri = uri; this.prefix = prefix; this.tagFileInfo = tagFileInfo; this.tagInfo = tagFileInfo.getTagInfo(); this.customNestingLevel = makeCustomNestingLevel(); this.childInfo = new ChildInfo(); this.implementsIterationTag = false; this.implementsBodyTag = false; this.implementsTryCatchFinally = false; this.implementsSimpleTag = true; this.implementsJspIdConsumer = false; this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes(); }
Example #7
Source File: JspHyperlinkProvider.java From netbeans with Apache License 2.0 | 6 votes |
private FileObject getTagFile(TokenSequence<?> tokenSequence, JspSyntaxSupport jspSup) { Token token = tokenSequence.token(); if (token.id() == JspTokenId.TAG) { String image = token.text().toString().trim(); if (image.startsWith("<")) { // NOI18N image = image.substring(1).trim(); } if (!image.startsWith("jsp:") && image.indexOf(':') != -1) { // NOI18N List l = jspSup.getTags(image); if (l.size() == 1) { TagLibraryInfo libInfo = ((TagInfo) l.get(0)).getTagLibrary(); if (libInfo != null) { TagFileInfo fileInfo = libInfo.getTagFile(getTagName(image)); if (fileInfo != null) { return JspUtils.getFileObject(jspSup.getDocument(), fileInfo.getPath()); } } } } } return null; }
Example #8
Source File: Node.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
public CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, TagFileInfo tagFileInfo) { super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); this.uri = uri; this.prefix = prefix; this.tagFileInfo = tagFileInfo; this.tagInfo = tagFileInfo.getTagInfo(); this.customNestingLevel = makeCustomNestingLevel(); this.childInfo = new ChildInfo(); this.implementsIterationTag = false; this.implementsBodyTag = false; this.implementsTryCatchFinally = false; this.implementsSimpleTag = true; this.implementsJspIdConsumer = false; this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes(); }
Example #9
Source File: TagFileProcessor.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public void visit(Node.CustomTag n) throws JasperException { TagFileInfo tagFileInfo = n.getTagFileInfo(); if (tagFileInfo != null) { String tagFilePath = tagFileInfo.getPath(); if (tagFilePath.startsWith("/META-INF/")) { // For tags in JARs, add the TLD and the tag as a dependency TldLocation location = compiler.getCompilationContext().getTldLocation( tagFileInfo.getTagInfo().getTagLibrary().getURI()); JarResource jarResource = location.getJarResource(); if (jarResource != null) { try { // Add TLD pageInfo.addDependant(jarResource.getEntry(location.getName()).toString(), Long.valueOf(jarResource.getJarFile().getEntry(location.getName()).getTime())); // Add Tag pageInfo.addDependant(jarResource.getEntry(tagFilePath.substring(1)).toString(), Long.valueOf(jarResource.getJarFile().getEntry(tagFilePath.substring(1)).getTime())); } catch (IOException ioe) { throw new JasperException(ioe); } } else { pageInfo.addDependant(tagFilePath, compiler.getCompilationContext().getLastModified( tagFilePath)); } } else { pageInfo.addDependant(tagFilePath, compiler.getCompilationContext().getLastModified( tagFilePath)); } Class<?> c = loadTagFile(compiler, tagFilePath, n.getTagInfo(), pageInfo); n.setTagHandlerClass(c); } visitBody(n); }
Example #10
Source File: Node.java From packagedrone with Eclipse Public License 1.0 | 5 votes |
public CustomTag(String jspVersion, String qName, String prefix, String localName, String uri, Attributes attrs, Mark start, Node parent, TagFileInfo tagFileInfo) { this(jspVersion, qName, prefix, localName, uri, attrs, null, null, start, parent, tagFileInfo); }
Example #11
Source File: TestTagPluginManager.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Test public void testBug54240() throws Exception { Tomcat tomcat = getTomcatInstance(); File appDir = new File("test/webapp-3.0"); Context ctx = tomcat.addWebapp(null, "/test", appDir.getAbsolutePath()); tomcat.start(); ServletContext context = ctx.getServletContext(); TagPluginManager manager = new TagPluginManager(context); Node.Nodes nodes = new Node.Nodes(); Node.CustomTag c = new Node.CustomTag("test:ATag", "test", "ATag", "http://tomcat.apache.org/jasper", null, null, null, null, null, new TagFileInfo("ATag", "http://tomcat.apache.org/jasper", tagInfo)); c.setTagHandlerClass(TesterTag.class); nodes.add(c); manager.apply(nodes, null, null); Node n = nodes.getNode(0); Assert.assertNotNull(n); Assert.assertTrue(n instanceof Node.CustomTag); Node.CustomTag t = (Node.CustomTag)n; Assert.assertNotNull(t.getAtSTag()); Node.Nodes sTag = c.getAtSTag(); Node scriptlet = sTag.getNode(0); Assert.assertNotNull(scriptlet); Assert.assertTrue(scriptlet instanceof Node.Scriptlet); Node.Scriptlet s = (Node.Scriptlet)scriptlet; Assert.assertEquals("//Just a comment", s.getText()); }
Example #12
Source File: TagFileProcessor.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public void visit(Node.CustomTag n) throws JasperException { TagFileInfo tagFileInfo = n.getTagFileInfo(); if (tagFileInfo != null) { String tagFilePath = tagFileInfo.getPath(); if (tagFilePath.startsWith("/META-INF/")) { // For tags in JARs, add the TLD and the tag as a dependency TldLocation location = compiler.getCompilationContext().getTldLocation( tagFileInfo.getTagInfo().getTagLibrary().getURI()); JarResource jarResource = location.getJarResource(); if (jarResource != null) { try { // Add TLD pageInfo.addDependant(jarResource.getEntry(location.getName()).toString(), Long.valueOf(jarResource.getJarFile().getEntry(location.getName()).getTime())); // Add Tag pageInfo.addDependant(jarResource.getEntry(tagFilePath.substring(1)).toString(), Long.valueOf(jarResource.getJarFile().getEntry(tagFilePath.substring(1)).getTime())); } catch (IOException ioe) { throw new JasperException(ioe); } } else { pageInfo.addDependant(tagFilePath, compiler.getCompilationContext().getLastModified( tagFilePath)); } } else { pageInfo.addDependant(tagFilePath, compiler.getCompilationContext().getLastModified( tagFilePath)); } Class<?> c = loadTagFile(compiler, tagFilePath, n.getTagInfo(), pageInfo); n.setTagHandlerClass(c); } visitBody(n); }
Example #13
Source File: TagLibraryInfo.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Get the TagFileInfo for a given tag name, looking through all the * tag files in this tag library. * * @param shortname The short name (no prefix) of the tag * @return the TagFileInfo for the specified Tag file, or null * if no Tag file is found * @since JSP 2.0 */ public TagFileInfo getTagFile(String shortname) { TagFileInfo tagFiles[] = getTagFiles(); if (tagFiles == null || tagFiles.length == 0) { return null; } for (int i=0; i < tagFiles.length; i++) { if (tagFiles[i].getName().equals(shortname)) { return tagFiles[i]; } } return null; }
Example #14
Source File: TestTagPluginManager.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Test public void testBug54240() throws Exception { Tomcat tomcat = getTomcatInstance(); File appDir = new File("test/webapp-3.0"); Context ctx = tomcat.addWebapp(null, "/test", appDir.getAbsolutePath()); tomcat.start(); ServletContext context = ctx.getServletContext(); TagPluginManager manager = new TagPluginManager(context); Node.Nodes nodes = new Node.Nodes(); Node.CustomTag c = new Node.CustomTag("test:ATag", "test", "ATag", "http://tomcat.apache.org/jasper", null, null, null, null, null, new TagFileInfo("ATag", "http://tomcat.apache.org/jasper", tagInfo)); c.setTagHandlerClass(TesterTag.class); nodes.add(c); manager.apply(nodes, null, null); Node n = nodes.getNode(0); Assert.assertNotNull(n); Assert.assertTrue(n instanceof Node.CustomTag); Node.CustomTag t = (Node.CustomTag)n; Assert.assertNotNull(t.getAtSTag()); Node.Nodes sTag = c.getAtSTag(); Node scriptlet = sTag.getNode(0); Assert.assertNotNull(scriptlet); Assert.assertTrue(scriptlet instanceof Node.Scriptlet); Node.Scriptlet s = (Node.Scriptlet)scriptlet; Assert.assertEquals("//Just a comment", s.getText()); }
Example #15
Source File: TagFileProcessor.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void visit(Node.CustomTag n) throws JasperException { TagFileInfo tagFileInfo = n.getTagFileInfo(); if (tagFileInfo != null) { String tagFilePath = tagFileInfo.getPath(); if (tagFilePath.startsWith("/META-INF/")) { // For tags in JARs, add the TLD and the tag as a dependency TldResourcePath tldResourcePath = compiler.getCompilationContext().getTldResourcePath( tagFileInfo.getTagInfo().getTagLibrary().getURI()); try (Jar jar = tldResourcePath.openJar()) { if (jar != null) { // Add TLD pageInfo.addDependant(jar.getURL(tldResourcePath.getEntryName()), Long.valueOf(jar.getLastModified(tldResourcePath.getEntryName()))); // Add Tag pageInfo.addDependant(jar.getURL(tagFilePath.substring(1)), Long.valueOf(jar.getLastModified(tagFilePath.substring(1)))); } else { pageInfo.addDependant(tagFilePath, compiler.getCompilationContext().getLastModified(tagFilePath)); } } catch (IOException ioe) { throw new JasperException(ioe); } } else { pageInfo.addDependant(tagFilePath, compiler.getCompilationContext().getLastModified(tagFilePath)); } Class<?> c = loadTagFile(compiler, tagFilePath, n.getTagInfo(), pageInfo); n.setTagHandlerClass(c); } visitBody(n); }
Example #16
Source File: TestTagPluginManager.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testBug54240() throws Exception { Tomcat tomcat = getTomcatInstanceTestWebapp(false, true); ServletContext context = ((Context) tomcat.getHost().findChildren()[0]).getServletContext(); TagPluginManager manager = new TagPluginManager(context); Node.Nodes nodes = new Node.Nodes(); Node.CustomTag c = new Node.CustomTag("test:ATag", "test", "ATag", "http://tomcat.apache.org/jasper", null, null, null, null, null, new TagFileInfo("ATag", "http://tomcat.apache.org/jasper", tagInfo)); c.setTagHandlerClass(TesterTag.class); nodes.add(c); manager.apply(nodes, null, null); Node n = nodes.getNode(0); Assert.assertNotNull(n); Assert.assertTrue(n instanceof Node.CustomTag); Node.CustomTag t = (Node.CustomTag)n; Assert.assertNotNull(t.getAtSTag()); Node.Nodes sTag = c.getAtSTag(); Node scriptlet = sTag.getNode(0); Assert.assertNotNull(scriptlet); Assert.assertTrue(scriptlet instanceof Node.Scriptlet); Node.Scriptlet s = (Node.Scriptlet)scriptlet; Assert.assertEquals("//Just a comment", s.getText()); }
Example #17
Source File: PageInfo.java From netbeans with Apache License 2.0 | 5 votes |
public String tagLibraryInfoToString(TagLibraryInfo info, String indent) { StringBuilder sb = new StringBuilder(); sb.append(indent).append("tlibversion : ").append(getFieldByReflection("tlibversion", info)).append('\n'); // NOI18N sb.append(indent).append("jspversion : ").append(info.getRequiredVersion()).append('\n'); // NOI18N sb.append(indent).append("shortname : ").append(info.getShortName()).append('\n'); // NOI18N sb.append(indent).append("urn : ").append(info.getReliableURN()).append('\n'); // NOI18N sb.append(indent).append("info : ").append(info.getInfoString()).append('\n'); // NOI18N sb.append(indent).append("uri : ").append(info.getURI()).append('\n'); // NOI18N TagInfo tags[] = info.getTags(); if (tags != null) { for (int i = 0; i < tags.length; i++) sb.append(tagInfoToString(tags[i], indent + " ")); // NOI18N } TagFileInfo tagFiles[] = info.getTagFiles().clone(); Arrays.sort(tagFiles, TAG_FILE_INFO_COMPARATOR); if (tagFiles != null) { for (int i = 0; i < tagFiles.length; i++) sb.append(tagFileToString(tagFiles[i], indent + " ")); // NOI18N } FunctionInfo functions[] = info.getFunctions(); if (functions != null) { for (int i = 0; i < functions.length; i++) sb.append(functionInfoToString(functions[i], indent + " ")); // NOI18N } return sb.toString(); }
Example #18
Source File: Node.java From tomcatsrc with Apache License 2.0 | 4 votes |
public CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Mark start, Node parent, TagFileInfo tagFileInfo) { this(qName, prefix, localName, uri, attrs, null, null, start, parent, tagFileInfo); }
Example #19
Source File: Node.java From Tomcat8-Source-Read with MIT License | 4 votes |
public CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Mark start, Node parent, TagFileInfo tagFileInfo) { this(qName, prefix, localName, uri, attrs, null, null, start, parent, tagFileInfo); }
Example #20
Source File: TagLibraryInfoImpl.java From packagedrone with Eclipse Public License 1.0 | 4 votes |
private TagFileInfo createTagFileInfo(TreeNode elem, String uri, URL jarFileUrl) throws JasperException { String name = null; String path = null; String description = null; String displayName = null; String icon = null; boolean checkConflict = false; Iterator list = elem.findChildren(); while (list.hasNext()) { TreeNode child = (TreeNode) list.next(); String tname = child.getName(); if ("name".equals(tname)) { name = child.getBody(); } else if ("path".equals(tname)) { path = child.getBody(); } else if ("description".equals(tname)) { checkConflict = true; description = child.getBody(); } else if ("display-name".equals(tname)) { checkConflict = true; displayName = child.getBody(); } else if ("icon".equals(tname)) { checkConflict = true; icon = child.getBody(); } else if ("example".equals(tname)) { // Ignore <example> element: Bugzilla 33538 } else if ("tag-extension".equals(tname)) { // Ignore <tag-extension> element: Bugzilla 33538 } else { err.jspError("jsp.error.unknown.element.in.tagfile", tname); } } if (path.startsWith("/META-INF/tags")) { // Tag file packaged in JAR // STARTJR: fix possible NPE if(jarFileUrl != null) { ctxt.getTagFileJarUrls().put(path, jarFileUrl); } // ENDJR: fix possible NPE } else if (!path.startsWith("/WEB-INF/tags")) { err.jspError("jsp.error.tagfile.illegalPath", path); } JasperTagInfo tagInfo = (JasperTagInfo) TagFileProcessor.parseTagFileDirectives(parserController, name, path, this); if (checkConflict) { String tstring = tagInfo.getInfoString(); if (tstring != null && !"".equals(tstring)) { description = tstring; } tstring = tagInfo.getDisplayName(); if (tstring != null && !"".equals(tstring)) { displayName = tstring; } tstring = tagInfo.getSmallIcon(); if (tstring != null && !"".equals(tstring)) { icon = tstring; } tagInfo = new JasperTagInfo( tagInfo.getTagName(), tagInfo.getTagClassName(), tagInfo.getBodyContent(), description, tagInfo.getTagLibrary(), tagInfo.getTagExtraInfo(), tagInfo.getAttributes(), displayName, icon, tagInfo.getLargeIcon(), tagInfo.getTagVariableInfos(), tagInfo.getDynamicAttributesMapName()); } return new TagFileInfo(name, path, tagInfo); }
Example #21
Source File: Node.java From packagedrone with Eclipse Public License 1.0 | 4 votes |
public TagFileInfo getTagFileInfo() { return tagFileInfo; }
Example #22
Source File: Node.java From Tomcat8-Source-Read with MIT License | 4 votes |
public TagFileInfo getTagFileInfo() { return tagFileInfo; }
Example #23
Source File: ImplicitTagLibraryInfo.java From packagedrone with Eclipse Public License 1.0 | 4 votes |
/** * Constructor. */ public ImplicitTagLibraryInfo(JspCompilationContext ctxt, ParserController pc, String prefix, String tagdir, ErrorDispatcher err) throws JasperException { super(prefix, null); this.pc = pc; this.err = err; this.pageInfo = pc.getCompiler().getPageInfo(); this.tagFileMap = new HashMap<String, String>(); this.vec = new ArrayList<TagFileInfo>(); // Implicit tag libraries have no functions: this.functions = new FunctionInfo[0]; tlibversion = TLIB_VERSION; jspversion = JSP_VERSION; if (!tagdir.startsWith(WEB_INF_TAGS)) { err.jspError("jsp.error.invalid.tagdir", tagdir); } // Determine the value of the <short-name> subelement of the // "imaginary" <taglib> element if (tagdir.equals(WEB_INF_TAGS) || tagdir.equals( WEB_INF_TAGS + "/")) { shortname = TAGS_SHORTNAME; } else { shortname = tagdir.substring(WEB_INF_TAGS.length()); shortname = shortname.replace('/', '-'); } // Populate mapping of tag names to tag file paths Set<String> dirList = ctxt.getResourcePaths(tagdir); if (dirList != null) { Iterator it = dirList.iterator(); while (it.hasNext()) { String path = (String) it.next(); if (path.endsWith(TAG_FILE_SUFFIX) || path.endsWith(TAGX_FILE_SUFFIX)) { /* * Use the filename of the tag file, without the .tag or * .tagx extension, respectively, as the <name> subelement * of the "imaginary" <tag-file> element */ String suffix = path.endsWith(TAG_FILE_SUFFIX) ? TAG_FILE_SUFFIX : TAGX_FILE_SUFFIX; String tagName = path.substring(path.lastIndexOf("/") + 1); tagName = tagName.substring(0, tagName.lastIndexOf(suffix)); tagFileMap.put(tagName, path); } else if (path.endsWith(IMPLICIT_TLD)) { String tldName = path.substring(path.lastIndexOf("/") + 1); if (IMPLICIT_TLD.equals(tldName)) { parseImplicitTld(ctxt, path); } } } } }
Example #24
Source File: JspDocumentParser.java From packagedrone with Eclipse Public License 1.0 | 4 votes |
private Node parseCustomAction( String qName, String localName, String uri, Attributes nonTaglibAttrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) throws SAXException { if (uri.startsWith(TagConstants.URN_JSPTLD)) { uri = uri.substring(TagConstants.URN_JSPTLD.length()); } // Check if this is a user-defined (custom) tag TagLibraryInfo tagLibInfo = pageInfo.getTaglib(uri); if (tagLibInfo == null) { return null; } TagInfo tagInfo = tagLibInfo.getTag(localName); TagFileInfo tagFileInfo = tagLibInfo.getTagFile(localName); if (tagInfo == null && tagFileInfo == null) { throw new SAXException( Localizer.getMessage("jsp.error.xml.bad_tag", localName, uri)); } Class tagHandlerClass = null; if (tagInfo != null) { String handlerClassName = tagInfo.getTagClassName(); try { tagHandlerClass = ctxt.getClassLoader().loadClass(handlerClassName); } catch (Exception e) { throw new SAXException( Localizer.getMessage("jsp.error.loadclass.taghandler", handlerClassName, qName), e); } } String prefix = ""; int colon = qName.indexOf(':'); if (colon != -1) { prefix = qName.substring(0, colon); } Node.CustomTag ret = null; if (tagInfo != null) { ret = new Node.CustomTag( tagLibInfo.getRequiredVersion(), qName, prefix, localName, uri, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent, tagInfo, tagHandlerClass); } else { ret = new Node.CustomTag( tagLibInfo.getRequiredVersion(), qName, prefix, localName, uri, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent, tagFileInfo); } return ret; }
Example #25
Source File: GetParseData.java From netbeans with Apache License 2.0 | 4 votes |
public TagFileInfoCacheRecord(long time, TagFileInfo info){ tagFileInfo = info; this.time = time; }
Example #26
Source File: TagLibraryInfoImpl.java From tomcatsrc with Apache License 2.0 | 4 votes |
private TagFileInfo createTagFileInfo(TreeNode elem, JarResource jarResource) throws JasperException { String name = null; String path = null; Iterator<TreeNode> list = elem.findChildren(); while (list.hasNext()) { TreeNode child = list.next(); String tname = child.getName(); if ("name".equals(tname)) { name = child.getBody(); } else if ("path".equals(tname)) { path = child.getBody(); } else if ("example".equals(tname)) { // Ignore <example> element: Bugzilla 33538 } else if ("tag-extension".equals(tname)) { // Ignore <tag-extension> element: Bugzilla 33538 } else if ("icon".equals(tname) || "display-name".equals(tname) || "description".equals(tname)) { // Ignore these elements: Bugzilla 38015 } else { if (log.isWarnEnabled()) { log.warn(Localizer.getMessage( "jsp.warning.unknown.element.in.tagfile", tname)); } } } if (path.startsWith("/META-INF/tags")) { // Tag file packaged in JAR // See https://bz.apache.org/bugzilla/show_bug.cgi?id=46471 // This needs to be removed once all the broken code that depends on // it has been removed ctxt.setTagFileJarResource(path, jarResource); } else if (!path.startsWith("/WEB-INF/tags")) { err.jspError("jsp.error.tagfile.illegalPath", path); } TagInfo tagInfo = TagFileProcessor.parseTagFileDirectives( parserController, name, path, jarResource, this); return new TagFileInfo(name, path, tagInfo); }
Example #27
Source File: TagLibraryInfoImpl.java From tomcatsrc with Apache License 2.0 | 4 votes |
private void parseTLD(String uri, InputStream in, JarResource jarResource) throws JasperException { Vector<TagInfo> tagVector = new Vector<TagInfo>(); Vector<TagFileInfo> tagFileVector = new Vector<TagFileInfo>(); Hashtable<String, FunctionInfo> functionTable = new Hashtable<String, FunctionInfo>(); ServletContext servletContext = ctxt.getServletContext(); boolean validate = Boolean.parseBoolean(servletContext.getInitParameter( Constants.XML_VALIDATION_TLD_INIT_PARAM)); String blockExternalString = servletContext.getInitParameter( Constants.XML_BLOCK_EXTERNAL_INIT_PARAM); boolean blockExternal; if (blockExternalString == null) { blockExternal = true; } else { blockExternal = Boolean.parseBoolean(blockExternalString); } // Create an iterator over the child elements of our <taglib> element ParserUtils pu = new ParserUtils(validate, blockExternal); TreeNode tld = pu.parseXMLDocument(uri, in); // Check to see if the <taglib> root element contains a 'version' // attribute, which was added in JSP 2.0 to replace the <jsp-version> // subelement this.jspversion = tld.findAttribute("version"); // Process each child element of our <taglib> element Iterator<TreeNode> list = tld.findChildren(); while (list.hasNext()) { TreeNode element = list.next(); String tname = element.getName(); if ("tlibversion".equals(tname) // JSP 1.1 || "tlib-version".equals(tname)) { // JSP 1.2 this.tlibversion = element.getBody(); } else if ("jspversion".equals(tname) || "jsp-version".equals(tname)) { this.jspversion = element.getBody(); } else if ("shortname".equals(tname) || "short-name".equals(tname)) this.shortname = element.getBody(); else if ("uri".equals(tname)) this.urn = element.getBody(); else if ("info".equals(tname) || "description".equals(tname)) this.info = element.getBody(); else if ("validator".equals(tname)) this.tagLibraryValidator = createValidator(element); else if ("tag".equals(tname)) tagVector.addElement(createTagInfo(element, jspversion)); else if ("tag-file".equals(tname)) { TagFileInfo tagFileInfo = createTagFileInfo(element, jarResource); tagFileVector.addElement(tagFileInfo); } else if ("function".equals(tname)) { // JSP2.0 FunctionInfo funcInfo = createFunctionInfo(element); String funcName = funcInfo.getName(); if (functionTable.containsKey(funcName)) { err.jspError("jsp.error.tld.fn.duplicate.name", funcName, uri); } functionTable.put(funcName, funcInfo); } else if ("display-name".equals(tname) || "small-icon".equals(tname) || "large-icon".equals(tname) || "listener".equals(tname)) { // Ignored elements } else if ("taglib-extension".equals(tname)) { // Recognized but ignored } else { if (log.isWarnEnabled()) { log.warn(Localizer.getMessage( "jsp.warning.unknown.element.in.taglib", tname)); } } } if (tlibversion == null) { err.jspError("jsp.error.tld.mandatory.element.missing", "tlib-version", uri); } if (jspversion == null) { err.jspError("jsp.error.tld.mandatory.element.missing", "jsp-version", uri); } this.tags = new TagInfo[tagVector.size()]; tagVector.copyInto(this.tags); this.tagFiles = new TagFileInfo[tagFileVector.size()]; tagFileVector.copyInto(this.tagFiles); this.functions = new FunctionInfo[functionTable.size()]; int i = 0; Enumeration<FunctionInfo> enumeration = functionTable.elements(); while (enumeration.hasMoreElements()) { this.functions[i++] = enumeration.nextElement(); } }
Example #28
Source File: Node.java From tomcatsrc with Apache License 2.0 | 4 votes |
public TagFileInfo getTagFileInfo() { return tagFileInfo; }
Example #29
Source File: PageInfo.java From netbeans with Apache License 2.0 | 4 votes |
@Override public int compare(TagFileInfo o1, TagFileInfo o2) { return o1.getPath().compareTo(o2.getPath()); }
Example #30
Source File: Parser.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
private void parseTaglibDirective(Node parent) throws JasperException { Attributes attrs = parseAttributes(); String uri = attrs.getValue("uri"); String prefix = attrs.getValue("prefix"); if (prefix != null) { Mark prevMark = pageInfo.getNonCustomTagPrefix(prefix); if (prevMark != null) { err.jspError(reader.mark(), "jsp.error.prefix.use_before_dcl", prefix, prevMark.getFile(), "" + prevMark.getLineNumber()); } if (uri != null) { String uriPrev = pageInfo.getURI(prefix); if (uriPrev != null && !uriPrev.equals(uri)) { err.jspError(reader.mark(), "jsp.error.prefix.refined", prefix, uri, uriPrev); } if (pageInfo.getTaglib(uri) == null) { TagLibraryInfoImpl impl = null; if (ctxt.getOptions().isCaching()) { impl = (TagLibraryInfoImpl) ctxt.getOptions() .getCache().get(uri); } if (impl == null) { TldLocation location = ctxt.getTldLocation(uri); impl = new TagLibraryInfoImpl(ctxt, parserController, pageInfo, prefix, uri, location, err, reader.mark()); if (ctxt.getOptions().isCaching()) { ctxt.getOptions().getCache().put(uri, impl); } } else { // Current compilation context needs location of cached // tag files for (TagFileInfo info : impl.getTagFiles()) { ctxt.setTagFileJarResource(info.getPath(), ctxt.getTagFileJarResource()); } } pageInfo.addTaglib(uri, impl); } pageInfo.addPrefixMapping(prefix, uri); } else { String tagdir = attrs.getValue("tagdir"); if (tagdir != null) { String urnTagdir = URN_JSPTAGDIR + tagdir; if (pageInfo.getTaglib(urnTagdir) == null) { pageInfo.addTaglib(urnTagdir, new ImplicitTagLibraryInfo(ctxt, parserController, pageInfo, prefix, tagdir, err)); } pageInfo.addPrefixMapping(prefix, urnTagdir); } } } new Node.TaglibDirective(attrs, start, parent); }