Monthly Archives: July 2013

Tomcat Web Application Directory Structure

What is webapps folder in tomcat?
webapps folder is the appBase for host name localhost.
This will be configured in conf/server.xml.


            unpackWARs=”true” autoDeploy=”true”>

you can change default webapps folder by editing appBase in host tag.


            unpackWARs=”true” autoDeploy=”true”>

What is exampleapp in the above image?
It is the name of the webapplication which is deployed in tomcat.

Here index.jsp is welcome file. This will be configured in web.xml file under WEB-INF folder.

–> this folder will contain all the images are used in this application.

This is optional folder.
Tomcat uses the Context configuration element to contain information about components required by a given application, such as databases, realms, or custom loaders.  Additionally, the Context element can be configured with a wide variety of attributes that control things such as loggingreload permissions, caching, and more.

This folder will not be visible to the end user.
This folder contains jar files (libs), java compiled codes(class files), properties files, xml’s and logs. 

–> this folder will have compiled codes of java files. 
Which will contain Java, Servlets, Filter , Struts, Hibernates (All java and j2ee codes ).. etc

This is the configuration file of web application.
Here Servlet, filter, web service mapping will be done with initial values.

How to install Balsamiq Mockups in Ubuntu?

Step 1 :

Copy the following code in a text file and save it as executable file. that is with .sh extension.

#!/usr/bin/env bash
if [ $EUID != 0 ]; then
    “This script must be run with sudo”
    exit $?

echo ”  Installing dependencies”
apt-get install ia32-libs -y # Note: This dep is a bit overkill but it’s useful anyway
ln -s /usr/lib/i386-linux-gnu/ /usr/lib/

echo ”  Downloading installers”
wget -P /tmp/
wget -P /tmp/

echo ”  Installing AIR”
chmod +x /tmp/AdobeAIRInstaller.bin
/tmp/AdobeAIRInstaller.bin -silent -eulaAccepted
echo ”  Installing Balsamiq”
dpkg -i /tmp/MockupsForDesktop32bit.deb

Step 2 :
Give chmod 777 permission to the file.

*** For 64 bit machine, change the mockup deb file name from 32 to 64.

JavaScript call() vs apply()

call() and apply() method are Function class’s core functions.

exaple 1 :-

function Product(name, price) { = name;
    this.price = price;

    if (price < 0)
        throw RangeError(‘Cannot create product “‘ + name + ‘” with a negative price’);
    return this;

function Food(name, price) {, arguments);
    this.category = ‘food’;
Food.prototype = new Product();

function Toy(name, price) {
    Product.apply(this, arguments);
    this.category = ‘toy’;
Toy.prototype = new Product();

var cheese = new Food(‘feta’, 5);
var fun = new Toy(‘robot’, 40);


exaple 2 :-

function theFunction(name, profession) {
    alert(“My name is ” + name + ” and I am a ” + profession + “.”);

theFunction(“John”, “fireman”);
theFunction.apply(undefined, [“Susan”, “school teacher”]);, “Claude”, “mathematician”);

call() :-
1. Any no of arguments to the function.
2. it will get parameters as like arguments to be passed to the function.

eg. this, a, b);
    . this will be the scope of the function.
    . u ll get function(a,b);

eg. this, array/string);
    . this will be the scope of the function.
    . u ll get function([a],b);

apply() :-
1. only two arguments to the function.
2. It ill get no of args based on the array lenth.

ie. this, arguments);
ie. this, array);

eg. this, [‘a’,’b’);
    . this will be the scope of the function.
    . u ll get function(a,b);

Reading Xml files in javascript using Ajax.

function XMLLoader (name, xmlPath){

            var xmlData;
   = name;
            this.xmlPath = xmlPath;

            var that = this;
                type: “GET”,
                url: this.xmlPath,
                dataType: “xml”,
                async: false,
                success: function(xml){
                    if (jQuery.browser.msie) {
                        var xmlDoc = new ActiveXObject(“Microsoft.XMLDOM”);
                        xml = xmlDoc;

                   xmlData = $(xml);

            return xmlData;