Props – Props are properties/arguments passed to the React JS Component/Function., Props values are rendered only when the page initially rendered output HTML/output. Change in Props will not be rendered dynamically in a web page. State – State are variables holding the state of the webpage.,Any change in state variables are rendered to the HTML/Output … Continue reading “What is State & Props? in React JS”
Author: admin
Configure Log4j2 -Java in minutes
Apache Log4j2 is used for printing info, error, debug, trace logging statements in enterprise applications. Apache Log4j2.x is an extension of Log4j1.x which has more significant features comparatively.Since major security vulnerabilities like Log4jShell & hacking possibilities are identified in Log4j1.x, it is always recommended to use Log4j2.x. It is pretty simple to configure Log4j2 in … Continue reading “Configure Log4j2 -Java in minutes”
Learn React JS in 5 minutes
What is React JS ? React is a Javascript library for creating User Interfaces. Simple For Interactive UI designs. Efficiently update the screens & render UI components with dynamic data from server. What is Single Page Application? In a Web Page, dynamic data will be loaded from server to page, without reloading the entire page., … Continue reading “Learn React JS in 5 minutes”
SimpleDateFormat (Parse Date)
Date conversions are very common scenarios in any application., Java Provides SimpleDateFormat class for String to Date, Date to String conversions. The below example shows How String format can be converted to Date Format. How to find difference between 2 Dates. Code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import java.text.SimpleDateFormat; import java.util.Date; class Example { public static void main(String args[]) { String date = "11/13/2018"; try { SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); Date parseDate = sdf.parse(date); System.out.println(parseDate); long differenceInMillis = new Date().getTime() - parseDate.getTime(); long differenceInDays = ((differenceInMillis/1000)/(60*60*24)); long year = differenceInDays/365; System.out.println("DifferenceInDays:"+differenceInDays); System.out.println("Age:"+year); } catch(Throwable t) { t.printStackTrace(); } } } |
Output
|
1 2 3 |
Tue Nov 13 00:00:00 UTC 2018 DifferenceInDays:1099 Age:3 |
Tranform XML using XSLT (XML XSLT)
To transform XML to another XML/HTML/TEXT format using XSLT., we need the following files. Input XML (.xml) XSLT file which contains the transformation script. (.xsl) The below XML (input.xml) input file, can be transformed into a html with the xsl (trans.xsl) file. Sample Input XML:File: input.xml
|
1 2 3 4 5 6 7 8 9 |
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="trans.xsl" type="text/xsl" ?> <Person> <Name>Sherlock</Name> <Profession>Detective</Profession> <Country>England</Country> </Person> |
In the above XML file, we could see … Continue reading “Tranform XML using XSLT (XML XSLT)”
What is XSLT?
XSLT is called as Extensible Stylesheet Language Tranformations. XSLT is a language to transform an XML document to another documents, like XML documents, HTML documents, Text Documents etc., Its a transformation language mainly used for transformation. For transformation of a XML Documents, the following file formats are used. An Input XML document which needs to … Continue reading “What is XSLT?”
XML – What is XPath?
The XPath language is a tree representation of XML documents. It allows the user to navigate around the document’s tree, selecting nodes by various criteria. Originally created to provide a common language and behavior model between XSLT and XPointer, XPATH is often used in other W3C standards For the below XML.,
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?xml version="1.0"?> <catalog> <book id="6260"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description>An in-depth look at creating applications with XML.</description> </book> <book id="2526"> <author>Ralls, Kim</author> <title>Midnight Rain</title> <genre>Fantasy</genre> <price>5.95</price> <publish_date>2000-12-16</publish_date> <description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</description> </book> </catalog> |
The XPATH to … Continue reading “XML – What is XPath?”
XML DOM – Document Object Model
DOM – Document Object Model is a language independent interface where each Node is an Object provides the data of the document in the XML tree structure. The standard is maintained by W3C (World Wide Web Consortium) XML DOM provides the details to get, change, add & delete XML elements in a XML document.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<!DOCTYPE html> <html> <head> </head> <body> Name:<span id="nodevaluename"></span><br/> Roll Number :<span id="nodevaluerollnumber"></span><br/> <script> function testXMLDoc() { var xmlString = "<?xml version=\"1.0\" standalone=\"yes\"?>" + "<Students>" + " <Department branch=\"Computer\"> " + " <Name> John </Name> " + " <RollNumber> 6260 </RollNumber> " + " </Department> " + "</Students>"; var domParser = new DOMParser(); var xmlDoc = domParser.parseFromString(xmlString, "text/xml"); document.getElementById("nodevaluename").innerHTML = (xmlDoc.getElementsByTagName("Name")[0].childNodes[0].nodeValue); document.getElementById("nodevaluerollnumber").innerHTML = new XMLSerializer().serializeToString(xmlDoc.getElementsByTagName("RollNumber")[0]); } testXMLDoc(); </script> </body> </html> |
XML Tree & Nodes
In a XML Document, each Element is called as Nodes., More than one Nodes, when they are linked together forms an XML., An XML contains one single parent element, and any number of child elements, and each child element again contains child elements on its own., and totally we can refer it as XML Tree., … Continue reading “XML Tree & Nodes”