Posts

Showing posts from March, 2012

JDOM Parser to Read and Update XML

JDom is a java based library for processing XML.  It is light weight and fast. It is simple to use since it was designed for Java. JDom Documents can be used with DOM tree or SAX events. JDom Support XPath. The following examples shows some common usecases with JDom such as 1) Update the value of a node in the xml 2) Print the xml from JDom Document 3) Get a particular Node using XPath //Update the value of a node Document doc = new SAXBuilder().build(new File(fileToProcess)); Element rootElement = doc.getRootElement(); Element book = rootElement.getChild("book").getChild("author") .setText("Sidd"); //Print the xml XMLOutputter outputter = new XMLOutputter(); outputter.output(doc, System.out); // Get a particular Node useing XPath XPath xPath = XPath.newInstance("/bookstore/book[bookid=$bookid]/bookid"); xPath.setVariable("bookid", "id1002"); Element guest = (Element) xPath.selectSingleNode(doc); System.out.pri

Eclipse plugin for maintaining copyright text in source code

Wondering how to maintain copyright or disclaimer text on source files. Specially when you have a number of files in your project, and you probably want to add some sort of info text or say copyright text as header in each and every file. Recently I found a easy simple to use eclipse plugin  http://www.wdev91.com/update/  which can be used easily to add or even replace existing header information text from source files. Since adding the text in each file is manually is very error prone and takes lots of effort, this plugin is very useful. You can find more information here  http://www.wdev91.com/

Failed to load or instantiate TagLibraryValidator

Problem Usecase: Downloaded the Apache Tag libraries and copied them in the web-inf /lib/jstl-libs/ folder. Included the taglib directory in jsp page, compiled and deployed in Tomcat 6. During runtime got the following exception. Exception Details [Truncated]: org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:281) org.apache.jasper.compiler.TagLibraryInfoImpl.createValidator(TagLibraryInfoImpl.java:670) org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:249) org.apache.jasper.compiler.TagLibraryInfoImpl. (TagLibraryInfoImpl.java:164) org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:386) org.apache.jasper.compi