Posted by: sureshk37 on: September 7, 2009
Backup:
/******************************************************/
//Database Properties
/******************************************************/
String dbName = “dbName”;
String dbUser = “dbUser”;
String dbPass = “dbPass”;
/***********************************************************/
// Execute Shell Command
/***********************************************************/
String executeCmd = “”;
executeCmd = “mysqldump -u “+dbUser+” -p”+dbPass+” “+dbName+” -r backup.sql”;
}
Process runtimeProcess =Runtime.getRuntime().exec(executeCmd);
int processComplete = runtimeProcess.waitFor();
if(processComplete == 0){
out.println(“Backup taken successfully”);
} else {
out.println(“Could not take mysql backup”);
}
Restore:
/******************************************************/
//Database Properties
/******************************************************/
String dbName = “dbName”;
String dbUser = “dbUser”;
String dbPass = “dbPass”;
/***********************************************************/
// Execute Shell Command
/***********************************************************/
String executeCmd = “”;
executeCmd = new String[]{“/bin/sh”, “-c”, “mysql -u” + dbUser+ ” -p”+dbPass+” ” + dbName+ ” < backup.sql” };
}
Process runtimeProcess =Runtime.getRuntime().exec(executeCmd);
int processComplete = runtimeProcess.waitFor();
if(processComplete == 0){
out.println(“success”);
} else {
out.println(“restore failure”);
}
Posted by: sureshk37 on: February 24, 2009
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
<script type=”text/javascript”>
function formValidate(){
//Name Validation
str = “”;
var fname = document.regForm.fname.value;
var regExp = /[a-z\s]/i;
var test = regExp.exec(fname);
if (test == null)
str += “Name is invalid or empty\n”;
//Date of Birth validation
var dob = document.regForm.dob.value;
var regExp = /(0[1-9]|(1|2)[0-9]|3[0-1])-(0[1-9]|1[0-2])-(19[0-9][0-9]|200[0-9])/;
var test = regExp.exec(dob);
if (test == null)
str += “Date of birth is invalid or empty\n”;
// Radio button validation
var checked = “”;
for (i = 0; i < document.regForm.radio.length; i++) {
if (document.regForm.radio[i].checked)
checked += document.regForm.radio[i].value;
}
if (checked == “”)
str += “Please select sex\n”;
// Drop down list validation
var qual = document.regForm.qual.value;
if (qual == “select”)
str += “Please select qualification\n”;
// Email validation
var email = document.regForm.email.value;
var regExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var test = regExp.exec(email);
if (test == null)
str += “Email is invalid or empty\n”;
// Phone number validation
var phone = document.regForm.phone.value;
var regExp = /0[0-9]{2,4}-([2-9])[0-9]{5,7}$/;
var test = regExp.exec(phone);
if (test == null)
str += “Phone number is invalid or empty\n”;
// Check box validation
var checked = “”;
for (i = 0; i < document.regForm.checkbox.length; i++) {
if (document.regForm.checkbox[i].checked)
checked += document.regForm.checkbox[i].value;
}
if (checked == “”)
str += “Please select the hobbies\n”;
alert(str);
return false;
}
</script>
</head>
<body>
<form action=”" method=”post” name=”regForm”>
Name : <input type=”text” id=”fname” name=”fname”>
<br>
Date of Birth : <input type=”text” name=”dob”>(dd-mm-yyyy)
<br>
Sex : <input type=”radio” name=”radio” value=”male”>Male
<input type=”radio” name=”radio” value=”female”>Female
<br>
Qualification :
<select name=”qual”>
<option value=”select”>Please Select</option>
<option value=”B.Tech”>B.tech</option>
<option value=”MCA”>MCA</option>
</select>
<br>
Email : <input type=”text” name=”email”>
<br>
Phone number : <input type=”text” name=”phone”>(for ex: 080-2322222)
<br>
Hobbies : <input type=”checkbox” name=”checkbox” value=”music”>Listening to Music
<input type=”checkbox” name=”checkbox” value=”books”>Reading Books
<input type=”checkbox” name=”checkbox” value=”sports”>Sports
<br>
<input type=”submit” value=”Submit” onclick=”return formValidate()”>
</form>
</body>
</html>

Form Validation
Posted by: sureshk37 on: February 24, 2009
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
<script type=”text/javascript”>
function removeOption(){
var select = document.getElementById(“softwares”);
for (i = 0; i < select.options.length; i++) {
if (select.options[i].selected) {
select.remove(i);
}
}
}
function addOption(){
var select = document.getElementById(“softwares”);
var option = document.createElement(“option”);
var text = document.createTextNode(“C”);
option.appendChild(text);
select.appendChild(option);
}
function removeAllOption(){
var select = document.getElementById(“softwares”);
for (i = select.options.length; i >= 0; i–) {
select.remove(i);
}
}
</script>
</head>
<body>
<select id=”softwares” multiple>
<option>Java</option>
<option>PHP</option>
<option>.NET</option>
<option>Perl</option>
</select>
<input type=”button” value=”Add option” onclick=”addOption()”>
<input type=”button” value=”Remove option” onclick=”removeOption()”>
<input type=”button” value=”Remove All” onclick=”removeAllOption()”>
</body>
</html>
Posted by: sureshk37 on: February 24, 2009
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
</head>
<body>
<select id=”softwares”>
<option>Java</option>
<option>PHP</option>
<option>.NET</option>
<option>Perl</option>
</select>
</body>
<script type=”text/javascript”>
var select = document.getElementById(“softwares”);
for (i = 0; i < select.options.length; i++) {
alert(select.options[i].text);
}
</script>
</html>
Posted by: sureshk37 on: February 23, 2009
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
<script type=”text/javascript”>
function addRow(){
var tab = document.getElementById(“myTable”);
var tr = document.createElement(‘tr’);
var td1 = document.createElement(‘td’);
var text1 = document.createTextNode(“Column1″);
var td2 = document.createElement(‘td’);
var text2 = document.createTextNode(“Column2″);
td1.appendChild(text1);
td2.appendChild(text2);
tr.appendChild(td1);
tr.appendChild(td2);
tab.appendChild(tr);
}
function removeRow(){
var tab = document.getElementById(“myTable”);
var row = tab.rows.length;
row -= 1;
tab.deleteRow(row);
}
</script>
</head>
<body>
<table id=”myTable” border=”1″>
<tr>
<td>
Column1
</td>
<td>
Column2
</td>
</tr>
</table>
<input type=”button” value=”Add new Row” onclick=”addRow()”><input type=”button” value=”Remove” onclick=”removeRow()”>
</body>
</html>
Posted by: sureshk37 on: February 23, 2009
The following code used to create table dynamically by using JavaScript DOM.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
</head>
<body>
<div id=”myTable” border=”1″></div>
</body>
<script type=”text/javascript”>
var con = document.getElementById(“myTable”);
var tab = document.createElement(‘table’);
tab.setAttribute(“border”, “1″);
var tr = document.createElement(‘tr’);
var td1 = document.createElement(‘td’);
var text1 = document.createTextNode(“Column1″);
var td2 = document.createElement(‘td’);
var text2 = document.createTextNode(“Column2″);
td1.appendChild(text1);
td2.appendChild(text2);
tr.appendChild(td1);
tr.appendChild(td2);
tab.appendChild(tr);
con.appendChild(tab);
</script>
</html>
Posted by: sureshk37 on: February 19, 2009
An absolutely Brilliant Joke, ENJOY!!!
A Woman was out golfing one day when she hit the
ball into the woods.
She went into the woods to look for it and found a frog
in a trap.
The frog said to her, ‘If you release me from this trap, I
will grant you three wishes.’
The woman freed the frog, and the frog said,
‘Thank you, but I failed to mention that there was a condition to your wishes.
Whatever you wish for, your husband will get ten times of it!’ The woman
said, ‘That’s okay.’
For her first wish, she wanted to be the most
beautiful woman in the world.
The frog warned her, ‘You do realize that this
wish will also make your husband the most handsome man in the world, an Adonis
whom women will flock to’.
The woman replied, ‘That’s okay, because I will
be the most beautiful woman and he will have eyes only for me.’
So, KAZAM-
she’s the most beautiful Woman in the world!
For her second wish, she
wanted to be the richest woman in the world.
The frog said, ‘That will make
your husband the richest man in the world. And he will be ten times richer than
you. ‘
The woman said, ‘That’s okay, because what’s mine is his and what’s
his is mine.’
So, KAZAM- she’s the richest woman in the world!
The
frog then inquired about her third wish, and she answered, ‘I’d like to have a
mild heart attack.’
Moral of the story: Women are clever. Don’t
mess with them.
Attention
female readers:
This is the end of the joke for you. Stop here and continue
feeling good!
Male
readers: Please scroll down.
The man had a heart attack ten times
‘milder’ than his wife!!!
Moral of the story : Women are really dumb but think they’re really smart .
Let them continue to think that way and just enjoy the show
PS: If you are a woman and are still reading this; it only goes to show that women never listen!!!
This is to all the guys for a good laugh, and to all the ladies who have a good sense of humour
ENJOY……. ……… ….
Posted by: sureshk37 on: February 16, 2009
God created the donkeyand said to him.
“You will be a donkey. You will work un-tiringly from sunrise to sunset
carrying burdens on your back. You will eat grass,
you will have no intelligence and you will live 50 years.”
The donkey answered:
“I will be a donkey, but to live 50years is much. Give me only 20years”
God granted his wish.
……………………………………………………………
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
God created the dog
and said to him:
“You will guard the house of man. You will be his best Friend.
You will eat the scraps that he gives you and
you will live 30years.
You will be a dog. “
The dog answered:
“Sir, to live 30years is too much,give me only15 years.
” God granted his wish.
……………………………………………………………….
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
God created the monkey
and said to him:
“You will be a monkey. You will swing from branch to branch doing tricks.
You will be amusing and you will live
20 years. “
The monkey
answered:
“To live 20years is too much, give me only 10years.”
God granted his wish.
……………………………………………………………
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Finally God created man…
and said to him:
“You will be man, the only rational creature on the face of the earth.
You will use your intelligence to become master over all the animals.
You will dominate the world and you will live 20years.”
Man responded:
“Sir, I will be a man but to live only
20 years is very little,
give me the 30years that the donkey refused,
the 15years that the dog did not want and
the 10years the monkey refused.
” God granted man’s wish ……………………………………………………….
And since then, man lives
20 years as a man ,
marries and spends
30 years like a donkey,
working and carrying all the burdens on his back.
Then when his children are grown,
he lives 15years like a dog taking care of the house
and eating whatever is given to him,
so that when he is old,
he can retire and live 10years like a monkey,
going from house to house and from one son or
daughter to another doing tricks to amuse his grandchildren.
That’s Life. .
__._,_.___
Posted by: sureshk37 on: February 16, 2009
Many working people often shift their houses. For them, it is difficult
to produce an address proof issued by Govt with latest address.
Our India post (post office) has come up with a solution.
Now you can get an Address proof along with your photo from India post.
Since the ID proof is issued by India post which is a central government
organization, it is similar to Govt ID cards like Driving license,
Voters ID etc. It can be used for opening bank accounts, for getting
telephone/internet connections etc.
The total cost for getting this ID card is Rs.250/ (Rs.10 for
application and Rs.240/- processing fee).
Inform everybody. This is very useful
For more details enquire in the nearest post office.
Posted by: sureshk37 on: January 27, 2009
There are two ways to include HTML file within another.
1) Server Side Includes (SSI)
2) Client Side Includes
Server Side Includes
For server side includes we need to do following steps,
(of course you need a web server to do the same..i.e Apache)
i) You need to enable the following extension options in apache configuration file (httpd.conf)
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
ii) Need to define Options in Directory directive.
Options +Includes
iii) The main html file name should be in .shtml extension. Lets say main.shtml
iv) Use the following syntax to include html file in main.shtml
<!–#include file=”another.html” –>
Client Side Includes
We dont have any specific syntax for client side includes.
Using javascript we can include the html file.
Lets assume that header.js contains the header information of the page. So we can include header.js like
<script language="javascript" src="header.js">
How ever we can use frame and iframe for include the html file within another.
Recent Comments