Deployment of Apache Tomcat 7 in Amazon server


 Before Installation Check your java Jdk installed or not.  
 Step 1:  
 Download the Apache tomcat 7 from the bellow link,  
 Step2:  
 md5sum apache-tomcat-[#].tar.gz  
 Next, extract the package:  
 tar xvzf apache-tomcat-[#].tar.gz  
 And move the extracted folder into a dedicated directory:  
 sudo mv apache-tomcat-[#] /usr/local/apache  
 Step3: Set the path   
 vi ~/.bashrc  
 export CATALINA_HOME=/usr/local/apache  
 Log out and log back into bash to have your changes take effect.  
 Step4: Start tomcat  
 sudo /usr/local/apache/bin/startup.sh  
 Step 5 : Check  
 Go to web browser and type ,  
 http://localhost:8080  

How to remove sudo password :



For the administrative password using sudo and sparing any lectures on why one would not want this...
Edit the sudoers file:  sudo visudo

Find this line:%sudo ALL=(ALL) ALL

Change the line:%sudo ALL=(ALL) NOPASSWD: ALL

Save and Exit. Voila! (Dont' shoot yourself in the foot, now. ;) By the way, you can become root and just type the password once.sudo su -  Now you ARE the root user, seeing no more password prompts. When you see guides referring to commands such as sudo some_command, just remove the "sudo" portion. In this way, you can choose to leave the security intact yet bypass it as you see fit.

If you are writing about your user account:

Open System Settings. Click on the User Accounts tile. Click the Unlock button and enter your password. Set the auto-login slider to the "on" position by dragging it to the right. Then click "Lock" to apply your changes.

Install Oracle java using terminal

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Deployment of Glassfish In amazon server

GlassFish is an open-source application server project started by Sun Microsystems for the Java EE platform and now sponsored by Oracle Corporation. The supported version is called Oracle GlassFish Server. GlassFish is free software, dual-licensed under two free software licences: the Common Development and Distribution License (CDDL) and the GNU General Public License (GPL) with the classpath exception.

GlassFish is the reference implementation of Java EE and as such supports Enterprise JavaBeans, JPA, JavaServer Faces, JMS, RMI, JavaServer Pages, servlets, etc. This allows developers to create enterprise applications that are portable and scalable, and that integrate with legacy technologies. Optional components can also be installed for additional services.




 Step 1:   
 Connect the Amazon server through terminal using DNS and the KEY.  
 To connect with amazon server:  
 ssh -i <key_path> <username>@<ip_adress_server>  
 First of all we need to check the java dependencies.  
 sudo apt-get update  
 sudo apt-get remove openjdk-6-jre-headless  
 sudo apt-get install sun-java6-jdk sun-java6-jre sun-java6-javadb  
 sudo apt-get autoremove  
 Step 2:  
 go to terminal in Ubuntu  
 go to your home directory in terminal   
 enter wget http://download.java.net/glassfish/4.0/release/glassfish-4.0.zip to download the glassfish in to your server.  
 Step 3:  
 Configure and change default port for Glassfish if tomcat already use port 8080.Because usually it use the port 4848.If you need as default please avoid thid Step 3.  
 vim glassfishv3/glassfish/domains/domain1/config/domain.xml  
 <network-listeners>  
 <network-listener port="8081" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool" />  
 <network-listener port="8181" protocol="http-listener-2" transport="tcp" name="http-listener-2" thread-pool="http-thread-pool" />  
 <network-listener port="4848" protocol="admin-listener" transport="tcp" name="admin-listener" thread-pool="http-thread-pool" />  
 </network-listeners>  
 Step 4:  
 Running by Glassfish  
 ./glassfishv3/glassfish/bin/asadmin start-domain --verbose  
 Step5:  
 Go to your-domain:8081 to see web page and your-domain:4848 for administrator pages  
 Glassfish Controls :  
 Create domain  
 Start and Stop Domain  
 Delete Domain  
 Enable secure Admin  

 Error may occur:  
 Solution:  
 http://charleech.wordpress.com/2012/03/23/glassfish-version-3-1-2-secure-admin-must-be-enabled-to-access-the-das-remotely/  
 http://coders-kitchen.com/tag/secure-admin-must-be-enabled-to-access-the-das-remotely/  

Super Html 5 Demos

http://hakim.se/experiments

Send message to specific user using socket.io

If we want to pass the message for a specific user who is in active. we need to get the socket Id of the specific user. By using the ID we can emit to single user. code is mentioned bellow.

io.sockets.socket(<ID of the user>).emit(<function name>,<variable>,<variables>);

Java Questions : 1

Problem I You are provided with a series of numbers as the input. You have to print a series of characters containing x and o depending on the value of each number. For each odd number, the printed pattern must end with an x. For even numbers, the pattern should end with an o. An empty line should be printed for the number zero.

Write a program to print a pattern looking at the examples given below.

All numbers will be integers (whole numbers) between 0 and 100. Sample Input The program would be run using command line parameters as shown below.

*Java:-** * java yourprogram 2 3 5 6 1

The output is shown below as it is accepted by the system.
*

xo
xox
xoxox
xoxoxo
x

*Sample Input 2 The program would be run using commandline parameters asshown below.

*Java:-** * java yourprogram 5 10 6 4 2 9
The output is shown below as it is accepted by the system.

*

xoxox
xoxoxoxoxo
xoxoxo
xoxo
xo
xoxoxoxox

*

handling Object in Javascript

A JavaScript object has properties associated with it. A property of an object can be explained as a variable that is attached to the object. Object properties are basically the same as ordinary JavaScript variables, except for the attachment to objects. The properties of an object define the characteristics of the object. You access the properties of an object with a simple dot-notation:

objectName.propertyName

Like all JavaScript variables, both the object name (which could be a normal variable) and property name are case sensitive. You can define a property by assigning it a value. For example, let's create an object named myCar and give it properties named make, model, and year as follows:

var myCar = new Object();
myCar.make = "Ford";
myCar.model = "Mustang";
myCar.year = 1969;


Properties of JavaScript objects can also be accessed or set using a bracket notation. Objects are sometimes called associative arrays, since each property is associated with a string value that can be used to access it. So, for example, you could access the properties of the myCar object as follows:

myCar["make"] = "Ford";
myCar["model"] = "Mustang";
myCar["year"] = 1969;


An object property name can be any valid JavaScript string, or anything that can be converted to a string, including the empty string. However, any property name that is not a valid JavaScript identifier (for example, a property name that has space or dash, or starts with a number) can only be accessed using the square bracket notation. This notation is also very useful when property names are to be dynamically determined (when the property name is not determined until runtime). Examples are as follows:

var myObj = new Object(),
str = "myString",
rand = Math.random(),
obj = new Object();

myObj.type = "Dot syntax";
myObj["date created"] = "String with space";
myObj[str] = "String value";
myObj[rand] = "Random Number";
myObj[obj] = "Object";
myObj[""] = "Even an empty string";

console.log(myObj);



Reference : 

Install Apache 2 In Linux


Apache is the web server piece of our puzzle. From within your terminal window issue the command:

sudo apt-get install apache2

If, by chance, you are using a distribution that does not use Sudo, you will need su to the root user and issue the above command without the sudo command.
Depending on your OS installation, the above command might need to pick up some dependencies. If so, okay those dependencies. At the end of the installation, Apache should automatically start. If it doesn't, issue the following command:

sudo /etc/init.d/apache2 start

You can now open up a browser and point it to the IP address (or domain) of the server to get the famous "It works!" page. You are ready to move on to PHP.