Monthly Archives: July 2013

31 july 2013 –> links reference

http://www.w3schools.com/html/html5_intro.asp
http://www.tutorialspoint.com/html5/
http://www.html5tutorial4u.com/
http://diveintohtml5.info/table-of-contents.html#storage
http://www.htmldog.com/reference/htmltags/
http://www.htmldog.com/reference/cssproperties/
http://webdesign.about.com/od/ssl/ht/new_selfsigned.htm
https://www.digitalocean.com/community/articles/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-12-04
http://www.java101.net/
http://www.javaexperience.com/run-multiple-tomcat-instances/
http://www.javacodegeeks.com/author/Rama-Krishnan/
http://www.ramkitech.com/p/all-posts.html
http://www.akadia.com/services/ssh_test_certificate.html
http://wiki.apache.org/tomcat/HowTo
http://sublimecodeintel.github.io/SublimeCodeIntel/
http://www.thegeekstuff.com/2011/03/install-apache2-ssl/
http://coding.smashingmagazine.com/2012/06/27/introduction-to-javascript-unit-testing/
http://www.webcomponentsshift.com/#1

Tomcat Load Balance using Apache and mod_jk.

What is load balance?
Load balance means dispatching the request between two or more tomcats.
Here all the tomcats which are wants to participante in the load balance will be grouped.
The Group of tomcat is called as tomcat clusters.
What is the need of load balance and tomcat cluster?
Mostly servers will run in single machine. There is a posibility anytime that machine can go down due to any os correption or harderware failure. So if it happens you cant access the server anymore.
So your site will be completely down. To resolve this we need tomcat cluster with load balance.
If any server goes down, the whole network will not go down. That is, if Load balancer receives any error message form a server it will redirect the request to the any of the remaining server. The servers in clusters will be selected using round robin method.
How to resolve the communication problem?
There is a way, By implementing load balancer you can resolve this issue. This load balancer will be added in from of all tomcat clusters. Here all the request and response will go through the load balancer.
So load balance will take care about dispatching the requests between tomcats which are in cluster.
There are Two effective load balancers are available.
  1. Apache http server
  2. Nginx
In this tutorial we are going to see Load balance using Apache Http Server.
What are the Software’s are required for Apache load balance?
  1. Apache Http server
  2. mod_jk
  3. tomcat cluster (many instances).
First install all the required softwares. In two different way you can install these, by using source code or apt-get. Using source code is always good because you can install only required things and at user specified place.
Here we are going to see how to build and install using source code.
How to install Apache Http Server?
First download the httpd server source code from http://httpd.apache.org/ then extract it and install.
You cant directly install using source code, you have to build to make Make file to install.
Steps to build:-
./configure –prefix=/usr/local/apache –enable-rewrite=shared–enable-proxy=shared
make
sudo make install

here
–prefix is the location where it is going to install in the machine.
–enable-rewrite and –enable-proxy options to enable these module in shared mode. These modules are not needed now. but we need in future for rewrite theURLbefore handover to next chain of servers and load-balancing support.
How to install mod_jk?
By using Apache http server alone we cant do load balance. Because by default Apache wont support AJP connector (ajp protocall).
So we need a linker to connect Apache web server and Ajp protocall. So here mod_jk going to be only a linker between appach and ajp protocall.
download the mod_jk connector module from http://tomcat.apache.org/download-connectors.cgiextract it and follow the given steps to build.
cd tomcat-connectors-1.2.37-src/native
./configure –with-apxs=/usr/local/apache/bin/apxs
make
sudo make install
here–with-apxsoption to specify where apxs module is located. so weneedto giveApachehttpd server location.
nowmod_jk.sofiles is created on modules directory in apache installed location (/usr/local/apache/modules)
How to configure mod_jk connector?
You have to do two thinks to configure mod_jk.
  1. Creating workers.properties file
  2. Configure mod_jk connector in apache httpd.conf file.
How to create workers.properties file?
Get into apache/conf folder and create workers.properties file.
Why workers.properties?
Its a configuration file to make communicate between tomcat and ajp protocal using mod_jk connector.
sample workers.properties :-

worker.list=balancer,stat

worker.tomcat1.type=ajp13
worker.tomcat1.port=8009
worker.tomcat1.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.port=8010
worker.tomcat2.host=localhost
worker.tomcat3.type=ajp13
worker.tomcat3.port=8011
worker.tomcat3.host=localhost
worker.balancer.type=lb
worker.balancer.balance_workers=tomcat1,tomcat2,tomcat3

worker.stat.type=status

type is ajp13, port is ajp port and host is tomcat instance.
Here tomcat name and balancer name is user defined names. So you can give any name whatever you want.
balancer type is lb. Its a special type for load balance.

Status property is optional. It is used to get the load balance status and logs.
All requests are received by balancer and those are handled and dispached by balance_workers.
Because balance_workers have all tomcat instances names which are participating in load balance.
Actually to forward the requests to the balance_workers we need to configure httpd.conf file.
Do refer the following line if you need more details abt workers.properties file.
How to configure httpd.conf file?
File path of httpd.conf is apache/conf/httpd.conf
Just add these following lines at the end of httpd.conf file.
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel emerg
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] ”
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat “%w %V %T”

JkMount / balancer
JkMount /status stat

* JkWorkersFile will represent the location of the workers.properties file.
* LoadModule is used to load mod_jk.so module.
The last 2 lines are important.
JkMount /status stat means any request to match the /status then that request forward to stat worker. Its status type worker. so its shows status of load balancer.
JkMount /* balancer this line matches all the request, so all request is forward to balancer worker. In balancer worker is uses the round robin algorithm to distribute the request to other tomcat instances.
What about tomcat instance failover?
There is a default property called worker.maintain.
Every 60 seconds worker.maintain will send request to update the status of the all tomcat instances. If worker.maintain didnt not receive respone from any instance it will update the status as fail.
This process will be continued. If it receives any response from instance’s it will update the status to ok.
Thats it. Try it.. if u get any doubt please do let me know.

Apache Virtual Hosts

Source From :-

Running several name-based web sites on a single IP address.

Your server has a single IP address, and multiple aliases (CNAMES) point to this machine in DNS. You want to run a web server for www.example.com and www.example.org on this machine.

Note

Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site. You can put entries in your hosts file for local testing, but that will work only from the machine with those hosts entries.

# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example.com

# Other directives here
VirtualHost>

<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example.org

# Other directives here
VirtualHost>

The asterisks match all addresses, so the main server serves no requests. Due to the fact that the virtual host with ServerName www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first VirtualHost.

Note

You can, if you wish, replace * with the actual IP address of the system, when you don’t care to discriminate based on the IP address or port.
However, it is additionally useful to use * on systems where the IP address is not predictable – for example if you have a dynamic IP address with your ISP, and you are using some variety of dynamic DNS solution. Since * matches any IP address, this configuration would work without changes whenever your IP address changes.

The above configuration is what you will want to use in almost all name-based virtual hosting situations. The only thing that this configuration will not work for, in fact, is when you are serving different content based on differing IP addresses or ports.

Name-based hosts on more than one IP address.

Note

Any of the techniques discussed here can be extended to any number of IP addresses.

The server has two IP addresses. On one (172.20.30.40), we will serve the “main” server, server.example.com and on the other (172.20.30.50), we will serve two or more virtual hosts.

Listen 80

# This is the "main" server running on 172.20.30.40
ServerName server.example.com
DocumentRoot /www/mainserver

<VirtualHost 172.20.30.50>
DocumentRoot /www/example1
ServerName www.example.com

# Other directives here ...
VirtualHost>

<VirtualHost 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example.org

# Other directives here ...
VirtualHost>

Any request to an address other than 172.20.30.50 will be served from the main server. A request to 172.20.30.50 with an unknown hostname, or no Host: header, will be served from www.example.com.

Serving the same content on different IP addresses (such as an internal and external address).

The server machine has two IP addresses (192.168.1.1 and 172.20.30.40). The machine is sitting between an internal (intranet) network and an external (internet) network. Outside of the network, the name server.example.com resolves to the external address (172.20.30.40), but inside the network, that same name resolves to the internal address (192.168.1.1).
The server can be made to respond to internal and external requests with the same content, with just one VirtualHost section.

<VirtualHost 192.168.1.1 172.20.30.40>
DocumentRoot /www/server1
ServerName server.example.com
ServerAlias server
VirtualHost>

Now requests from both networks will be served from the same VirtualHost.

Note:

On the internal network, one can just use the name server rather than the fully qualified host name server.example.com.
Note also that, in the above example, you can replace the list of IP addresses with *, which will cause the server to respond the same on all addresses.

Running different sites on different ports.

You have multiple domains going to the same IP and also want to serve multiple ports. The example below illustrates that the name-matching takes place after the best matching IP address and port combination is determined.

Listen 80
Listen 8080

<VirtualHost 172.20.30.40:80>
ServerName www.example.com
DocumentRoot /www/domain-80
VirtualHost>

<VirtualHost 172.20.30.40:8080>
ServerName www.example.com
DocumentRoot /www/domain-8080
VirtualHost>

<VirtualHost 172.20.30.40:80>
ServerName www.example.org
DocumentRoot /www/otherdomain-80
VirtualHost>

<VirtualHost 172.20.30.40:8080>
ServerName www.example.org
DocumentRoot /www/otherdomain-8080
VirtualHost>

IP-based virtual hosting

The server has two IP addresses (172.20.30.40 and 172.20.30.50) which resolve to the names www.example.com and www.example.org respectively.

Listen 80

<VirtualHost 172.20.30.40>
DocumentRoot /www/example1
ServerName www.example.com
VirtualHost>

<VirtualHost 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example.org
VirtualHost>

Requests for any address not specified in one of the directives (such as localhost, for example) will go to the main server, if there is one.

Mixed port-based and ip-based virtual hosts

The server machine has two IP addresses (172.20.30.40 and 172.20.30.50) which resolve to the names www.example.com and www.example.org respectively. In each case, we want to run hosts on ports 80 and 8080.

Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080

<VirtualHost 172.20.30.40:80>
DocumentRoot /www/example1-80
ServerName www.example.com
VirtualHost>

<VirtualHost 172.20.30.40:8080>
DocumentRoot /www/example1-8080
ServerName www.example.com
VirtualHost>

<VirtualHost 172.20.30.50:80>
DocumentRoot /www/example2-80
ServerName www.example.org
VirtualHost>

<VirtualHost 172.20.30.50:8080>
DocumentRoot /www/example2-8080
ServerName www.example.org
VirtualHost>

Mixed name-based and IP-based vhosts

Any address mentioned in the argument to a virtualhost that never appears in another virtual host is a strictly IP-based virtual host.

Listen 80
<VirtualHost 172.20.30.40>
DocumentRoot /www/example1
ServerName www.example.com
VirtualHost>

<VirtualHost 172.20.30.40>
DocumentRoot /www/example2
ServerName www.example.org
VirtualHost>

<VirtualHost 172.20.30.40>
DocumentRoot /www/example3
ServerName www.example.net
VirtualHost>

# IP-based
<VirtualHost 172.20.30.50>
DocumentRoot /www/example4
ServerName www.example.edu
VirtualHost>

<VirtualHost 172.20.30.60>
DocumentRoot /www/example5
ServerName www.example.gov
VirtualHost>

Using Virtual_host and mod_proxy together

The following example allows a front-end machine to proxy a virtual host through to a server running on another machine. In the example, a virtual host of the same name is configured on a machine at 192.168.111.2. The ProxyPreserveHost On directive is used so that the desired hostname is passed through, in case we are proxying multiple hostnames to a single machine.

<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://192.168.111.2/
ProxyPassReverse / http://192.168.111.2/
ServerName hostname.example.com
VirtualHost>

Using _default_ vhosts

_default_ vhosts for all ports

Catching every request to any unspecified IP address and port, i.e., an address/port combination that is not used for any other virtual host.

<VirtualHost _default_:*>
DocumentRoot /www/default
VirtualHost>

Using such a default vhost with a wildcard port effectively prevents any request going to the main server.
A default vhost never serves a request that was sent to an address/port that is used for name-based vhosts. If the request contained an unknown or no Host: header it is always served from the primary name-based vhost (the vhost for that address/port appearing first in the configuration file).
You can use AliasMatch or RewriteRule to rewrite any request to a single information page (or script).

_default_ vhosts for different ports

Same as setup 1, but the server listens on several ports and we want to use a second _default_ vhost for port 80.

<VirtualHost _default_:80>
DocumentRoot /www/default80
# ...
VirtualHost>

<VirtualHost _default_:*>
DocumentRoot /www/default
# ...
VirtualHost>

The default vhost for port 80 (which must appear before any default vhost with a wildcard port) catches all requests that were sent to an unspecified IP address. The main server is never used to serve a request.

_default_ vhosts for one port

We want to have a default vhost for port 80, but no other default vhosts.

<VirtualHost _default_:80>
DocumentRoot /www/default
...
VirtualHost>

A request to an unspecified address on port 80 is served from the default vhost. Any other request to an unspecified address and port is served from the main server.
Any use of * in a virtual host declaration will have higher precedence than _default_.

Migrating a name-based vhost to an IP-based vhost

The name-based vhost with the hostname www.example.org (from our name-based example, setup 2) should get its own IP address. To avoid problems with name servers or proxies who cached the old IP address for the name-based vhost we want to provide both variants during a migration phase.
The solution is easy, because we can simply add the new IP address (172.20.30.50) to the VirtualHost directive.

Listen 80
ServerName www.example.com
DocumentRoot /www/example1

<VirtualHost 172.20.30.40 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example.org
# ...
VirtualHost>

<VirtualHost 172.20.30.40>
DocumentRoot /www/example3
ServerName www.example.net
ServerAlias *.example.net
# ...
VirtualHost>

The vhost can now be accessed through the new address (as an IP-based vhost) and through the old address (as a name-based vhost).

Using the ServerPath directive

We have a server with two name-based vhosts. In order to match the correct virtual host a client must send the correct Host: header. Old HTTP/1.0 clients do not send such a header and Apache has no clue what vhost the client tried to reach (and serves the request from the primary vhost). To provide as much backward compatibility as possible we create a primary vhost which returns a single page containing links with an URL prefix to the name-based virtual hosts.

<VirtualHost 172.20.30.40>
# primary vhost
DocumentRoot /www/subdomain
RewriteEngine On
RewriteRule . /www/subdomain/index.html
# ...
VirtualHost>

<VirtualHost 172.20.30.40>
DocumentRoot /www/subdomain/sub1
ServerName www.sub1.domain.tld
ServerPath /sub1/
RewriteEngine On
RewriteRule ^(/sub1/.*) /www/subdomain$1
# ...
VirtualHost>

<VirtualHost 172.20.30.40>
DocumentRoot /www/subdomain/sub2
ServerName www.sub2.domain.tld
ServerPath /sub2/
RewriteEngine On
RewriteRule ^(/sub2/.*) /www/subdomain$1
# ...
VirtualHost>

Due to the ServerPath directive a request to the URL http://www.sub1.domain.tld/sub1/ is always served from the sub1-vhost.
A request to the URL http://www.sub1.domain.tld/ is only served from the sub1-vhost if the client sent a correct Host: header. If no Host: header is sent the client gets the information page from the primary host.
Please note that there is one oddity: A request to http://www.sub2.domain.tld/sub1/ is also served from the sub1-vhost if the client sent no Host: header.
The RewriteRule directives are used to make sure that a client which sent a correct Host: header can use both URL variants, i.e., with or without URL prefix.

How to setup Virtual host in tomcat?

Virtual hosting means, setting up many websites under single tomcat.
That is hosting many websites into single tomcat.
What is the use of Virtual host method?
Virtual hosting is what most personal and small websites use for hosting. Instead of having a dedicated IP and machine where only your website lives, your site is hosted on a server with a bunch of other websites. In fact, most hosting today is on a virtual host.
For example if you want to run many website means, u should have to buy hosting space or server.
Instead of buying server/space you d\can deploy all your webapplications into single tomcat.
This process is called as Virtual hosting.
Where to configure?
Open tomcat/conf/server.xml
Give all the host name under section in server.xml
eg..
www.anand.com” appBase=”anand_webapps” unpackWARS=”true” autoDeploy=”true” />
Copy tomcat/webapps folder and copy it parallel to webapps folder and rename it to appBase name in .
And deploy a war file into each appBase folders.
like this you can host any number of websites.
We can simulate the DNS setup in /etc/hosts file.
Open file /etc/hosts and give the following entries.

192.168.1.15 www.anand.com
192.168.1.15 www.anand1.com
192.168.1.15 www.anand2.com
How it is working?
Each and every tomcat request will have details about the host in header. This host header will be checked with host’s which are given under section in server.xml.
If mached with any host, then tomcat will be pointed to corresponding appBase folder given in host and the request will be processed.
Thats it..
Type ur host name in browser and check it
Refer :-

How to Run Multiple Tomcat instancess in same machine?

Hi all in this post we are going to see, running multiple tomcat in a machine.
Before start you make sure that java is installed in your machine. Because to workwith tomcat you need java.
If u need any assistance to install java. Please refer post How to install java7 ?
What is apache and tomcat?
Apache-tomcat is a http server (web server).
Apache server is good to process static files like html, css and images.
Apache will process only static files, it wont process java or any backend files.
Tomcat server is good to process java (ie. Backend). Even Tomcat can process static files but when compare to apache, apache is best to load static files.
Difference between apache server and tomcat server?
Difference between webserver and application server?
How to install tomcat?
You can install tomcat in two different ways.
  1. Install throught terminal using sudo apt-get install tomcat ccommand.
eg. Sudo apt-get install tomcat7 manager admin user fonts.
    1. Download tomcate server from apache site and extract the tar.
Please refer post How to install tomcat? If you have any doubt.
In this post we are going to see second method.
How to run multiple tomcat?
Keep three copies of tomcat folder and name it like tomcat1, tomcat2, tomcat3.
Open tomcat1/conf/server.xml .
Give unique port address for connectors shutdown, http connector and Ajp connector of each
tomcat instances.
Start each tomcats.
Deploy any war file in each web apps folder.
How to deploy web application in to tomcat?
You can do it in two different ways.
  1. Copy war file difectly into tomcat/webapps folder.
  2. Through tomcat manager.
    • To delpoy throught tomcat you have to set tomcat user name and password.
    • For reference please refer post How to set tomcat username and password?.
Thats it … open tomcat url with correct http port.

How to enable ssl in tomcat?

First Generate SSl cirtificate.
If you don’t know about generating SSL certificate, please read post How to generate ssl certificate?
Then open tomcat/conf/server.xml
Go to ssl connector tag.
Add the following properties to the connector tag.
keystoreFile=”{{certificate location in ur machine}}”
keystorePass=”{{password of the certificate}}”
Test tomcat.
Eg https://localhost:8080/

how to convert ip from dynamic to static in ubuntu?

Source From :-
http://www.unixmen.com/how-to-convert-my-ip-from-dynamic-to-static-in-ubuntu/

 1. First edit network interface using your favorite text editor/terminal :

    sudo vi /etc/network/interfaces
    sudo nano /etc/network/interfaces
    sudo gedit /etc/network/interfaces

Normally you  are  using   eth0  for  card  ethernet  you will see  some  thing  like  this :

    auto eth0
    iface eth0 inet dhcp

2. Remove line 2 and add:

    auto eth0
    iface eth0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1

    save a and  exit

    192.168.1.100 suppose  to be  your  static  IP you can change it  to  the IP   you  want

    192.168.1.1 is  the  router  IP

Now we’ll need to add in the DNS settings by editing the resolv.conf file:

    sudo vi /etc/resolv.conf

and  add  the 2 ip adresss  of  your  DNS servers  ( internet provider)

3- remove dhcp client

In terminal, type the following command:

    sudo apt-get remove dhcp-client

4- Restart network

    sudo /etc/init.d/networking restart

Now you shloud have a static IP instead of dynamic one.

Is done.

First edit network interface using your favorite text editor :

sudo vi /etc/network/interfaces

Normally you  are  using   eth0  for  card  ethernet  you will see  some  thing  like  this :

auto eth0
iface eth0 inet dhcp

Remove line 2 and add:

auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

save a and  exit
192.168.1.100 suppose  to be  your  static  IP you can change it  to  the IP   you  want
192.168.1.1 is  the  router  IP

Now we’ll need to add in the DNS settings by editing the resolv.conf file:

sudo vi /etc/resolv.conf

and  add  the 2 ip adresss  of  your  DNS servers  ( internet provider)
3- remove dhcp client
In terminal, type the following command:

sudo apt-get remove dhcp-client

4- Restart network

sudo /etc/init.d/networking restart

Now you shloud have a static IP instead of dynamic one.
Is done.
– See more at: http://www.unixmen.com/how-to-convert-my-ip-from-dynamic-to-static-in-ubuntu/#sthash.jV5JJv6s.dpuf

First edit network interface using your favorite text editor :

sudo vi /etc/network/interfaces

Normally you  are  using   eth0  for  card  ethernet  you will see  some  thing  like  this :

auto eth0
iface eth0 inet dhcp

Remove line 2 and add:

auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

save a and  exit
192.168.1.100 suppose  to be  your  static  IP you can change it  to  the IP   you  want
192.168.1.1 is  the  router  IP

Now we’ll need to add in the DNS settings by editing the resolv.conf file:

sudo vi /etc/resolv.conf

and  add  the 2 ip adresss  of  your  DNS servers  ( internet provider)
3- remove dhcp client
In terminal, type the following command:

sudo apt-get remove dhcp-client

4- Restart network

sudo /etc/init.d/networking restart

Now you shloud have a static IP instead of dynamic one.
Is done.
– See more at: http://www.unixmen.com/how-to-convert-my-ip-from-dynamic-to-static-in-ubuntu/#sthash.jV5JJv6s.dpuf

First edit network interface using your favorite text editor :

sudo vi /etc/network/interfaces

Normally you  are  using   eth0  for  card  ethernet  you will see  some  thing  like  this :

auto eth0
iface eth0 inet dhcp

Remove line 2 and add:

auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

save a and  exit
192.168.1.100 suppose  to be  your  static  IP you can change it  to  the IP   you  want
192.168.1.1 is  the  router  IP

Now we’ll need to add in the DNS settings by editing the resolv.conf file:

sudo vi /etc/resolv.conf

and  add  the 2 ip adresss  of  your  DNS servers  ( internet provider)
3- remove dhcp client
In terminal, type the following command:

sudo apt-get remove dhcp-client

4- Restart network

sudo /etc/init.d/networking restart

Now you shloud have a static IP instead of dynamic one.
Is done.
– See more at: http://www.unixmen.com/how-to-convert-my-ip-from-dynamic-to-static-in-ubuntu/#sthash.jV5JJv6s.dpuf

First edit network interface using your favorite text editor :

sudo vi /etc/network/interfaces

Normally you  are  using   eth0  for  card  ethernet  you will see  some  thing  like  this :

auto eth0
iface eth0 inet dhcp

Remove line 2 and add:

auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

save a and  exit
192.168.1.100 suppose  to be  your  static  IP you can change it  to  the IP   you  want
192.168.1.1 is  the  router  IP

Now we’ll need to add in the DNS settings by editing the resolv.conf file:

sudo vi /etc/resolv.conf

and  add  the 2 ip adresss  of  your  DNS servers  ( internet provider)
3- remove dhcp client
In terminal, type the following command:

sudo apt-get remove dhcp-client

4- Restart network

sudo /etc/init.d/networking restart

Now you shloud have a static IP instead of dynamic one.
Is done.
– See more at: http://www.unixmen.com/how-to-convert-my-ip-from-dynamic-to-static-in-ubuntu/#sthash.jV5JJv6s.dpuf

How to Deploy .war file into Tomcat?

There is two way to deploy war (web archive file) in to tomcat.
Method 1: –
Copying war file directly into tomcat/webapps folder.
While start tomcat this .war files will be extracted.
Method 2: –
Deploying through tomcat manager.
For this you need to username and password for tomcat manager.
.war file will be extracted once it is deployed.
Its good practice to restart server once war file is deployed.

Struts Folder Structure in Tomcat (Apache)

Source From :-

Struts is one of the MVC Based Web frameworks in Java EE. It is used in creating simple web applications that are more flexible and easy to debug. Many of the blogs till have written about the folder structure of Struts and now i am going to discuss about the neat folder structure of struts in the Apache Tomcat version 7/6/5 or below.

The structure is mostly similar to that of the structure of the servlets/jsp. A little change can be noted here.

webapps
     |-index.html
     |-custom.html
     |-myjsp.jsp
     |-hello.jsp
     |-WEB-INF
            |-classes
                 |-MyAction.java
                 |-MyAction.class
                 |-MyBean.java
                 |-MyBean.class
                 |-MyRequestProcessor.java
                 |-MyRequestProcessor.class
            |-lib
                |-struts-core-1.3.10.jar
                |-struts-taglib-1.3.10.jar
                |-commons-beanutils-1.8.0.jar
                |-commons-chain-1.2.jar
                |-commons-digester-1.8.jar
                |-commons-logging-1.0.4.jar
                |-commons-validator-1.3.1.jar
            |-web.xml
            |-struts-config.xml

Note: Additional jar files in the lib directory may be needed example, struts-tiles-1.3.10.jar is necessary when you do use the tiles framework.

The classes directory: The classes directory should contain the relevant classes i.e. the Action class, Form Bean class (optional), MyRequestProcessor (Your own RequestProcessor class [Optional]), the Model class (optional). Optional means that these classes are not needed at all situations i.e. all applications. Usually a bean class and Model class is used when you interact with database. Helloworld example does not make use of these classes.

HTML Files: The HTML files and jsps are also seen in the servlets/jsp. So that is it.

web.xml: The web.xml file does the same thing as in the servlets. But with a little bit of change, later discussed on other posts.

struts-config.xml: This is the file that maps the action class for some user’s request. It is specified in the web.xml file. Note: As is specified in the web.xml, you can rename struts-config.xml to myconfig.myext and can also change where it is located. Whatever you do, you must specify the complete path along with the name and extension of this file in the web.xml.

webapps: Webapps folder is the webapps folder in the Tomcat. It comes by default when you install your tomcat. 

– See more at: http://java-demos.blogspot.in/2012/09/struts-folder-structure-for-apache.html#sthash.xobJngMW.dpuf

Servlets Folder Structure in Apache Tomcat

Webapps directory in Tomcat:
—————————————————
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\

Note: Program Files is the place where software is installed in your computer, there you will find Apache Software Foundation, and there, Tomcat <version_installed>, in it webapps folder is present.
webapps
|_ project_name
|           |_ myhtml.html
|           |_ index.html
|_ WEB-INF
|   |_ classes
|          |_ MyServlet.java
|          |_ MyServlet.class
|_ web.xml
Description:
———————————–
1. webapps contain project_name folder.
2. project_name folder may contain html files and WEB-INF directory is must.
3. WEB-INF folder contains web.xml and classes folder.
4. classes folder contains servlet classes.