Posts

Showing posts from 2011

Custom HTML Tags using JavScript

Custom Tags in HTML using JavaScript. Browsers allow us to use a predefined set of HTML tags. There are times when we want to use our own tags in our html documents. Custom tags in server side scripting Server side scripting languages have the feature of adding our own tags to the server side scripts such as jsp. For example we use jsp tag libraries to achieve this in java. There is no big magic in this. The tag library actually prints a creates a HTMl code snippet for the given tags and replace the original html with these constructed HTML. The custm tag is converted to html before it is seen by the browser. But at the end the browsers see only predefined html tags. Custom tag in JavaScript Is it possible to make the browser react to a custom tag when it encounters such one in the DOM? This is possible using JavaScript, when the browser encounters your custom tag, it can handl it like any other valid predefined tag. Consider we have custom tag  <mytag id="mtag&q

XML parsing PULL and PUSH methodologies.

What is XML push parsing? A push parsing model is a model where the parser pushes parsing events to the application. SAX (stands for Simple API for XML) is the most common example of a push parsing API for XML. An application using SAX would define a number of callback that would be called by the parser when certain events occur. for example, an application can define a startElement method, that the parser will call every time it sees the beginning of a new element. SAX is a one-pass parser that goes through the document once from begging to end and sends one event to the calling application for each XML construct it encounters. What is XML pull parsing? A pull parsing mode is a model in which the application drives the parser (in contrast to the push model, where the parser drives the application), by pulling parsed xml constructs from the parser one by one, according to its needs. StAX (Streaming API for XML) is the most prevalent Java pull parsing API. in the StAX model, an a

Javascript A simple grayed out overlay

Overlay One of the most adopted feature of web2.0 is the use of a grayed out overlay panel. Overlay is useful to insert a new page inside the current page.. Almost all the javascript libraries available today comes with the overlay feature inbuilt. Below is the code snippet for overlay using plain js and html without any libraries. Code <HTML> <BODY> The javascript code to display and hide the overlay. <script type="text/javascript"> function disable1() { var blurDiv = document.createElement("div"); blurDiv.id = "blurDiv"; blurDiv.style.cssText = "position:absolute; top:0; right:0; width:" + screen.width + "px; height:" + screen.height + "px;background-color: #000000; opacity:0.5; filter:alpha(opacity=50)"; var aDiv = document.createElement("div"); aDiv.appendChild(document.createTextNode("Overlay panel")); aDiv.id = "aDiv"

Debugging minified/obfuscated javascript on production

What is minified or packed JS  Minification is the practice of removing unnecessary characters from code to reduce its size thereby improving load times. When code is minified all comments are removed, as well as unneeded white space characters (space, newline, and tab). In the case of JavaScript, this improves response time performance because the size of the downloaded file is reduced. Two popular tools for minifying JavaScript code are JSMin and YUI Compressor.  YUI compressor to minify a js  java -jar yuicompressor*.jar inputFile.js -o inputFile-min.js   Obfuscation  Obfuscation is an alternative optimization that can be applied to source code. Like minification, it removes comments and white space, but it also munges the code. As part of munging, function and variable names are converted into smaller strings making the code more compact as well as harder to read.   Debugging minified js  Following the best practices, the javascript files in production are minified/

Jconsole configuration - Tomcat

JMX local/remote monitoring configuration for tomcat using JConsole. Start tomcat with the following self-explanatory params. 1. -Dcom.sun.management.jmxremote=true 2. -Dcom.sun.management.jmxremote.port=8181 3. -Dcom.sun.management.jmxremote.authenticate=false 4. -Dcom.sun.management.jmxremote.ssl=false These two params are to solve RMI transport issues of java 1.6 5. -Djava.rmi.server.hostname=localhost 6. -Djava.net.preferIPv4Stack=true Unix/Linux export CATALINA_OPTS="-Dcon.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=8181 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" Windows On windows set each parameter separately, otherwise you must use line separator (\). set CATALINA_OPTS=-Dcom.sun.management.jmxremote=true set CATALINA_OPTS=%CATALINA_OPTS% -Dcom.sun.management.jmxremote.port=8181 set CATALINA_OPTS=%CATALINA_OPTS% -Dcom.sun.management.jmxremote.authenticate=false