Enter Key Works Same as Tab
save as main.html
Just Run On Any browser
<form action=”" method=”POST”>
<input name=”output1″ type=”text” id=”output1″ onKeyDown=”if(event.keyCode==13) event.keyCode=9;”/>
<input name=”output2″ type=”text” id=”output2″ onKeyDown=”if(event.keyCode==13) event.keyCode=9;”/>
<input name=”output3″ type=”text” id=”output3″ onKeyDown=”if(event.keyCode==13) event.keyCode=9;”/>
<input name=”output4″ type=”text” id=”output4″ onKeyDown=”if(event.keyCode==13) event.keyCode=9;”/>
</form>
Enter Key Works Same as Tab, tab to enter key, Use of enter key in behalf of Tab key. Cursor handle by enter key.
View Example From Simple Code In Html
Html To Pdf In java
/***@Amish Kumar Aman**/
//Simple Code To make Pdf from Html
package com.secure.connection;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.html.simpleparser.HTMLWorker;
import com.lowagie.text.html.simpleparser.StyleSheet;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.codec.Base64;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
public class HtmlToPdf {
public static void createPdfDocument(String htmlPath,String pdfPath)throws Exception
{
Document pdfDocument = new Document();
Reader htmlreader = new BufferedReader(new InputStreamReader(
new FileInputStream(htmlPath)
));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(pdfDocument, baos);
pdfDocument.open();
StyleSheet styles = new StyleSheet();
styles.loadTagStyle(“body”, “font”, “Bitstream Vera Sans”);
ArrayList arrayElementList = HTMLWorker.parseToList(htmlreader, styles);
for (int i = 0; i < arrayElementList.size(); ++i) {
Element e = (Element) arrayElementList.get(i);
pdfDocument.add(e);
}
pdfDocument.close();
byte[] bs = baos.toByteArray();
String pdfBase64 = Base64.encodeBytes(bs); //output
File pdfFile = new File(pdfPath);
FileOutputStream out = new FileOutputStream(pdfFile);
out.write(bs);
out.close();
}
}
Send Mail Code In Swing
First Of all You Have to download Two Jar Files. 1. mail.jar
2.activation.jar
Code To Send Mail From Swing :
//start of the code
import javax.mail.*;
import javax.mail.internet.*;
import java.net.InetAddress;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.activation.*;
class SwingMailer extends Frame implements ActionListener {
Label l1,l2,l3,l4,l5;
TextField to,from,subject,attchments,res;
TextArea content;
Button b1;
SwingMailer(){
setLayout(new FlowLayout());
l1 = new Label(“To:”,Label.RIGHT);
l2 = new Label(“From:”,Label.RIGHT);
l3= new Label(“Subject:”,Label.RIGHT);
l4= new Label(“content:”,Label.RIGHT);
l5= new Label(“attchments:”,Label.RIGHT);
to = new TextField(20);
from = new TextField(20);
subject = new TextField(20);
attchments = new TextField(20);
content = new TextArea(6,20);
b1 = new Button(“Send Mail”);
res = new TextField(20);
this.add(l1);
this.add(to);
this.add(l2);
this.add(from);
this.add(l3);
this.add(subject);
this.add(l4);
this.add(content);
this.add(l5);
this.add(attchments);
this.add(b1);
this.add(res);
to.addActionListener(this);
to.setBackground(new Color(90,45,30));
to.setForeground(Color.white);
from.addActionListener(this);
from.setBackground(new Color(90,45,30));
from.setForeground(Color.white);
subject.addActionListener(this);
subject.setBackground(new Color(90,45,30));
subject.setForeground(Color.white);
attchments.addActionListener(this);
attchments.setBackground(new Color(90,45,30));
attchments.setForeground(Color.white);
res.addActionListener(this);
res.setBackground(new Color(90,45,30));
res.setForeground(Color.white);
Font f1 = new Font(“Sans Serif”,Font.BOLD,15);
content.setFont(f1);
content.setForeground(Color.red);
content.setBackground(Color.black);
b1.setBackground(Color.green);
b1.setForeground(Color.red);
b1.addActionListener(this);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent ae)
{
try{
String ogms = “aaa.bbb.ccc.ddd”;
//set your domain ip here.
Properties props = System.getProperties();
String mailer = “MyMailerProgram”;
props.put(“mail.smtp.host”, ogms);
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from.getText()));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to.getText(), false));
//enable if Message is likly to be a html
// msg.setContentType(“text/html”);
msg.setSubject(subject.getText());
msg.setHeader(“X-Mailer”, mailer);
//msg.setText(content.getText());
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(content.getText());
MimeBodyPart mbp2 = new MimeBodyPart();
FileDataSource fds= new FileDataSource(attchments.getText());
mbp2.setDataHandler( new DataHandler(fds));
mbp2.setFileName(attchments.getText());
MimeMultipart mp;
mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
msg.setContent(mp);
Transport.send(msg);
res.setText(“You’r Mail Successfully Sent”);
repaint();
}
catch(Exception e) {
}
}
public void paint(Graphics g)
{
setBackground(new Color(50,50,70));
}
public static void main(String[] argv)
throws Exception{
SwingMailer s = new SwingMailer();
s.setSize(250,450);
s.setTitle(“www.yourdomain.com”);
s.show();
}
}
//end of the code
Compilation Method : Copy the Downloaded Jar in to lib folder.
and just Complied it.
READ WEB PAGE FROM YOUR OWN END AND MANAGE YOUR DATABASE FROM IT
READ WEB PAGE FROM YOUR OWN END AND MANAGE YOUR DATABASE FROM IT
- // READ WEBSITE :
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
public class ReadWebPage {
public static void main(String[] args) throws IOException {
String urltext = "http://www.java2all.wordpress.com";
URL url = new URL(urltext);
BufferedReader in = new BufferedReader(new InputStreamReader(url
.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
// Process each line.
System.out.println(inputLine);
}
in.close();
}
}
loading Propery File In java
package com;
/* @auther Amish Kumar Aman*/
/* load Property Files in java*/
/*getting value from property Files in My Eclipse*/
import java.util.Properties;
import java.util.Enumeration;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.FileInputStream;
public class PropertyFiles {
public static Properties createDefaultProperties() {
Properties tempProp = new Properties();
tempProp.setProperty(“path”, “jdbc:mysql://localhost:3306/”);
tempProp.setProperty(“dbname”, “vlgt”);
tempProp.setProperty(“dbuser”, “root”);
tempProp.setProperty(“dbpassword”, “”);
tempProp.setProperty(“driver”, “org.gjt.mm.mysql.Driver”);
tempProp.setProperty(“proxy”, “808″);
tempProp.setProperty(“proxyip”, “localhost”);
proxyip=127.0.0.1 or localhost
tempProp.setProperty(“pdf”, “user.dir”);
tempProp.setProperty(“pdf_next”, “pdf”);
return tempProp;
}
public static void printProperties(Properties p, String s) {
System.out.println();
System.out.println(“========================================”);
System.out.println(s);
System.out.println(“========================================”);
System.out.println(“+—————————————+”);
System.out.println(“| Print Application Properties |”);
System.out.println(“+—————————————+”);
p.list(System.out);
System.out.println();
}
public static void saveProperties(Properties p, String fileName) {
OutputStream propsFile;
try {
propsFile = new FileOutputStream(fileName);
p.store(propsFile, “Properties File to the Test Application”);
propsFile.close();
} catch (IOException ioe) {
System.out.println(“I/O Exception.”);
ioe.printStackTrace();
System.exit(0);
}
}
public static Properties loadProperties(String fileName) {
InputStream propsFile;
Properties tempProp = new Properties();
try {
propsFile = new FileInputStream(fileName);
tempProp.load(propsFile);
propsFile.close();
} catch (IOException ioe) {
System.out.println(“I/O Exception.”);
ioe.printStackTrace();
System.exit(0);
}
return tempProp;
}
public static Properties alterProperties(Properties p) {
Properties newProps = new Properties();
Enumeration enProps = p.propertyNames();
String key = “”;
while ( enProps.hasMoreElements() ) {
key = (String) enProps.nextElement();
log_level = Integer.parseInt(props.getProperty(“log_level”));
database_oid = Long.parseLong(props.getProperty(“database_oid”));
if (!key.equals(“fake_entry”)) {
if (key.equals(“log_level”)) {
newProps.setProperty(key, “3″);
} else {
newProps.setProperty(key, p.getProperty(key));
}
}
}
return newProps;
}
public static void main(String[] args) {
final String PROPFILE= “myProp.properties”;
Properties myProp;
Properties myNewProp;
myProp = createDefaultProperties();
printProperties(myProp, “Newly Created (Default) Properties”);
saveProperties(myProp, PROPFILE);
myNewProp = loadProperties(PROPFILE);
printProperties(myNewProp, “Loaded Properties”);
myNewProp = alterProperties(myProp);
printProperties(myNewProp, “After Altering Properties”);
saveProperties(myNewProp, PROPFILE);
}
}
java jsp scrollbars and search in table
// searchable.js
function filterTable(term, table) {
dehighlight(table);
var terms = term.value.toLowerCase().split(” “);
for (var r = 1; r < table.rows.length; r++) {
var display = ”;
for (var i = 0; i < terms.length; i++) {
if (table.rows[r].innerHTML.replace(/<[^>]+>/g, “”).toLowerCase()
.indexOf(terms[i]) < 0) {
display = ‘none’;
} else {
if (terms[i].length) highlight(terms[i], table.rows[r]);
}
table.rows[r].style.display = display;
}
}
}
/*
* Transform back each
* <span>preText <span class=”highlighted”>term</span> postText</span>
* into its original
* preText term postText
*/
function dehighlight(container) {
for (var i = 0; i < container.childNodes.length; i++) {
var node = container.childNodes[i];
if (node.attributes && node.attributes['class']
&& node.attributes['class'].value == ‘highlighted’) {
node.parentNode.parentNode.replaceChild(
document.createTextNode(
node.parentNode.innerHTML.replace(/<[^>]+>/g, “”)),
node.parentNode);
// Stop here and process next parent
return;
} else if (node.nodeType != 3) {
// Keep going onto other elements
dehighlight(node);
}
}
}
/*
* Create a
* <span>preText <span class=”highlighted”>term</span> postText</span>
* around each search term
*/
function highlight(term, container) {
for (var i = 0; i < container.childNodes.length; i++) {
var node = container.childNodes[i];
if (node.nodeType == 3) {
// Text node
var data = node.data;
var data_low = data.toLowerCase();
if (data_low.indexOf(term) >= 0) {
//term found!
var new_node = document.createElement(‘span’);
node.parentNode.replaceChild(new_node, node);
var result;
while ((result = data_low.indexOf(term)) != -1) {
new_node.appendChild(document.createTextNode(
data.substr(0, result)));
new_node.appendChild(create_node(
document.createTextNode(data.substr(
result, term.length))));
data = data.substr(result + term.length);
data_low = data_low.substr(result + term.length);
}
new_node.appendChild(document.createTextNode(data));
}
} else {
// Keep going onto other elements
highlight(term, node);
}
}
}
function create_node(child) {
var node = document.createElement(‘span’);
node.setAttribute(‘class’, ‘highlighted’);
node.attributes['class'].value = ‘highlighted’;
node.appendChild(child);
return node;
}
/*
* Here is the code used to set a filter on all sortable elements, usually I
* use the behaviour.js library which does that just fine
*/
tables = document.getElementsByTagName(‘table’);
for (var t = 0; t < tables.length; t++) {
element = tables[t];
if (element.attributes['class']
&& element.attributes['class'].value == ‘sortable’) {
/* Here is dynamically created a form */
var form = document.createElement(‘form’);
form.setAttribute(‘id’,'jsform’);
form.setAttribute(‘class’, ‘filter’);
// For ie…
form.attributes['class'].value = ‘filter’;
var inputText= document.createElement(‘span’);
inputText.innerHTML=’Search Here : ’;
var input = document.createElement(‘input’);
input.value=’Search Here….’;
input.accessKey=’s';
var ShortCut= document.createElement(‘span’);
ShortCut.className=’smallFont’;
ShortCut.innerHTML=’[ Alt + s ]‘;
input.onclick= function()
{
input.value=”;
}
input.onkeyup = function() {
filterTable(input, element);
}
form.appendChild(inputText);
form.appendChild(input);
form.appendChild(ShortCut);
element.parentNode.insertBefore(form, element);
}
}
//sorttable.js
var stIsIE = /*@cc_on!@*/false;
sorttable = {
init: function() {
// quit if this function has already been called
if (arguments.callee.done) return;
// flag this function so we don’t do the same thing twice
arguments.callee.done = true;
// kill the timer
if (_timer) clearInterval(_timer);
if (!document.createElement || !document.getElementsByTagName) return;
sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
forEach(document.getElementsByTagName(‘table’), function(table) {
if (table.className.search(/\bsortable\b/) != -1) {
sorttable.makeSortable(table);
}
});
},
makeSortable: function(table) {
if (table.getElementsByTagName(‘thead’).length == 0) {
// table doesn’t have a tHead. Since it should have, create one and
// put the first table row in it.
the = document.createElement(‘thead’);
the.appendChild(table.rows[0]);
table.insertBefore(the,table.firstChild);
}
// Safari doesn’t support table.tHead, sigh
if (table.tHead == null) table.tHead = table.getElementsByTagName(‘thead’)[0];
if (table.tHead.rows.length != 1) return; // can’t cope with two header rows
// Sorttable v1 put rows with a class of “sortbottom” at the bottom (as
// “total” rows, for example). This is B&R, since what you’re supposed
// to do is put them in a tfoot. So, if there are sortbottom rows,
// for backwards compatibility, move them to tfoot (creating it if needed).
sortbottomrows = [];
for (var i=0; i<table.rows.length; i++) {
if (table.rows[i].className.search(/\bsortbottom\b/) != -1) {
sortbottomrows[sortbottomrows.length] = table.rows[i];
}
}
if (sortbottomrows) {
if (table.tFoot == null) {
// table doesn’t have a tfoot. Create one.
tfo = document.createElement(‘tfoot’);
table.appendChild(tfo);
}
for (var i=0; i<sortbottomrows.length; i++) {
tfo.appendChild(sortbottomrows[i]);
}
delete sortbottomrows;
}
// work through each column and calculate its type
headrow = table.tHead.rows[0].cells;
for (var i=0; i<headrow.length; i++) {
// manually override the type with a sorttable_type attribute
if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col
mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
if (mtch) { override = mtch[1]; }
if (mtch && typeof sorttable["sort_"+override] == ‘function’) {
headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
} else {
headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);
}
// make it clickable to sort
headrow[i].sorttable_columnindex = i;
headrow[i].sorttable_tbody = table.tBodies[0];
dean_addEvent(headrow[i],”click”, function(e) {
if (this.className.search(/\bsorttable_sorted\b/) != -1) {
// if we’re already sorted by this column, just
// reverse the table, which is quicker
sorttable.reverse(this.sorttable_tbody);
this.className = this.className.replace(‘sorttable_sorted’,
‘sorttable_sorted_reverse’);
this.removeChild(document.getElementById(‘sorttable_sortfwdind’));
sortrevind = document.createElement(‘span’);
sortrevind.id = “sorttable_sortrevind”;
sortrevind.innerHTML = stIsIE ? ‘ <font face=”webdings”>5</font>’ : ‘ ▴’;
this.appendChild(sortrevind);
return;
}
if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
// if we’re already sorted by this column in reverse, just
// re-reverse the table, which is quicker
sorttable.reverse(this.sorttable_tbody);
this.className = this.className.replace(‘sorttable_sorted_reverse’,
‘sorttable_sorted’);
this.removeChild(document.getElementById(‘sorttable_sortrevind’));
sortfwdind = document.createElement(‘span’);
sortfwdind.id = “sorttable_sortfwdind”;
sortfwdind.innerHTML = stIsIE ? ‘ <font face=”webdings”>6</font>’ : ‘ ▾’;
this.appendChild(sortfwdind);
return;
}
// remove sorttable_sorted classes
theadrow = this.parentNode;
forEach(theadrow.childNodes, function(cell) {
if (cell.nodeType == 1) { // an element
cell.className = cell.className.replace(‘sorttable_sorted_reverse’,”);
cell.className = cell.className.replace(‘sorttable_sorted’,”);
}
});
sortfwdind = document.getElementById(‘sorttable_sortfwdind’);
if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
sortrevind = document.getElementById(‘sorttable_sortrevind’);
if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
this.className += ‘ sorttable_sorted’;
sortfwdind = document.createElement(‘span’);
sortfwdind.id = “sorttable_sortfwdind”;
sortfwdind.innerHTML = stIsIE ? ‘ <font face=”webdings”>6</font>’ : ‘ ▾’;
this.appendChild(sortfwdind);
row_array = [];
col = this.sorttable_columnindex;
rows = this.sorttable_tbody.rows;
for (var j=0; j<rows.length; j++) {
row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]];
}
/* If you want a stable sort, uncomment the following line */
//sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
/* and comment out this one */
row_array.sort(this.sorttable_sortfunction);
tb = this.sorttable_tbody;
for (var j=0; j<row_array.length; j++) {
tb.appendChild(row_array[j][1]);
}
delete row_array;
});
}
}
},
guessType: function(table, column) {
// guess the type of a column based on its first non-blank row
sortfn = sorttable.sort_alpha;
for (var i=0; i<table.tBodies[0].rows.length; i++) {
text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]);
if (text != ”) {
if (text.match(/^-?[�$�]?[\d,.]+%?$/)) {
return sorttable.sort_numeric;
}
// check for a date: dd/mm/yyyy or dd/mm/yy
// can have / or . or – as separator
// can be mm/dd as well
possdate = text.match(sorttable.DATE_RE)
if (possdate) {
// looks like a date
first = parseInt(possdate[1]);
second = parseInt(possdate[2]);
if (first > 12) {
// definitely dd/mm
return sorttable.sort_ddmm;
} else if (second > 12) {
return sorttable.sort_mmdd;
} else {
// looks like a date, but we can’t tell which, so assume
// that it’s dd/mm (English imperialism!) and keep looking
sortfn = sorttable.sort_ddmm;
}
}
}
}
return sortfn;
},
getInnerText: function(node) {
// gets the text we want to use for sorting for a cell.
// strips leading and trailing whitespace.
// this is *not* a generic getInnerText function; it’s special to sorttable.
// for example, you can override the cell text with a customkey attribute.
// it also gets .value for <input> fields.
hasInputs = (typeof node.getElementsByTagName == ‘function’) &&
node.getElementsByTagName(‘input’).length;
if (node.getAttribute(“sorttable_customkey”) != null) {
return node.getAttribute(“sorttable_customkey”);
}
else if (typeof node.textContent != ‘undefined’ && !hasInputs) {
return node.textContent.replace(/^\s+|\s+$/g, ”);
}
else if (typeof node.innerText != ‘undefined’ && !hasInputs) {
return node.innerText.replace(/^\s+|\s+$/g, ”);
}
else if (typeof node.text != ‘undefined’ && !hasInputs) {
return node.text.replace(/^\s+|\s+$/g, ”);
}
else {
switch (node.nodeType) {
case 3:
if (node.nodeName.toLowerCase() == ‘input’) {
return node.value.replace(/^\s+|\s+$/g, ”);
}
case 4:
return node.nodeValue.replace(/^\s+|\s+$/g, ”);
break;
case 1:
case 11:
var innerText = ”;
for (var i = 0; i < node.childNodes.length; i++) {
innerText += sorttable.getInnerText(node.childNodes[i]);
}
return innerText.replace(/^\s+|\s+$/g, ”);
break;
default:
return ”;
}
}
},
reverse: function(tbody) {
// reverse the rows in a tbody
newrows = [];
for (var i=0; i<tbody.rows.length; i++) {
newrows[newrows.length] = tbody.rows[i];
}
for (var i=newrows.length-1; i>=0; i–) {
tbody.appendChild(newrows[i]);
}
delete newrows;
},
/* sort functions
each sort function takes two parameters, a and b
you are comparing a[0] and b[0] */
sort_numeric: function(a,b) {
aa = parseFloat(a[0].replace(/[^0-9.-]/g,”));
if (isNaN(aa)) aa = 0;
bb = parseFloat(b[0].replace(/[^0-9.-]/g,”));
if (isNaN(bb)) bb = 0;
return aa-bb;
},
sort_alpha: function(a,b) {
if (a[0]==b[0]) return 0;
if (a[0]<b[0]) return -1;
return 1;
},
sort_ddmm: function(a,b) {
mtch = a[0].match(sorttable.DATE_RE);
y = mtch[3]; m = mtch[2]; d = mtch[1];
if (m.length == 1) m = ’0′+m;
if (d.length == 1) d = ’0′+d;
dt1 = y+m+d;
mtch = b[0].match(sorttable.DATE_RE);
y = mtch[3]; m = mtch[2]; d = mtch[1];
if (m.length == 1) m = ’0′+m;
if (d.length == 1) d = ’0′+d;
dt2 = y+m+d;
if (dt1==dt2) return 0;
if (dt1<dt2) return -1;
return 1;
},
sort_mmdd: function(a,b) {
mtch = a[0].match(sorttable.DATE_RE);
y = mtch[3]; d = mtch[2]; m = mtch[1];
if (m.length == 1) m = ’0′+m;
if (d.length == 1) d = ’0′+d;
dt1 = y+m+d;
mtch = b[0].match(sorttable.DATE_RE);
y = mtch[3]; d = mtch[2]; m = mtch[1];
if (m.length == 1) m = ’0′+m;
if (d.length == 1) d = ’0′+d;
dt2 = y+m+d;
if (dt1==dt2) return 0;
if (dt1<dt2) return -1;
return 1;
},
shaker_sort: function(list, comp_func) {
// A stable sort function to allow multi-level sorting of data
// see: http://en.wikipedia.org/wiki/Cocktail_sort
// thanks to Joseph Nahmias
var b = 0;
var t = list.length – 1;
var swap = true;
while(swap) {
swap = false;
for(var i = b; i < t; ++i) {
if ( comp_func(list[i], list[i+1]) > 0 ) {
var q = list[i]; list[i] = list[i+1]; list[i+1] = q;
swap = true;
}
} // for
t–;
if (!swap) break;
for(var i = t; i > b; –i) {
if ( comp_func(list[i], list[i-1]) < 0 ) {
var q = list[i]; list[i] = list[i-1]; list[i-1] = q;
swap = true;
}
} // for
b++;
} // while(swap)
}
}
if (document.addEventListener) {
document.addEventListener(“DOMContentLoaded”, sorttable.init, false);
}
/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
document.write(“<script id=__ie_onload defer src=javascript:void(0)><\/script>”);
var script = document.getElementById(“__ie_onload”);
script.onreadystatechange = function() {
if (this.readyState == “complete”) {
sorttable.init(); // call the onload handler
}
};
/*@end @*/
/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
var _timer = setInterval(function() {
if (/loaded|complete/.test(document.readyState)) {
sorttable.init(); // call the onload handler
}
}, 10);
}
/* for other browsers */
window.onload = sorttable.init;
// written by Dean Edwards, 2005
// with input from Tino Zijdel, Matthias Miller, Diego Perini
// http://dean.edwards.name/weblog/2005/10/add-event/
function dean_addEvent(element, type, handler) {
if (element.addEventListener) {
element.addEventListener(type, handler, false);
} else {
// assign each event handler a unique ID
if (!handler.$$guid) handler.$$guid = dean_addEvent.guid++;
// create a hash table of event types for the element
if (!element.events) element.events = {};
// create a hash table of event handlers for each element/event pair
var handlers = element.events[type];
if (!handlers) {
handlers = element.events[type] = {};
// store the existing event handler (if there is one)
if (element["on" + type]) {
handlers[0] = element["on" + type];
}
}
// store the event handler in the hash table
handlers[handler.$$guid] = handler;
// assign a global event handler to do all the work
element["on" + type] = handleEvent;
}
};
// a counter used to create unique IDs
dean_addEvent.guid = 1;
function removeEvent(element, type, handler) {
if (element.removeEventListener) {
element.removeEventListener(type, handler, false);
} else {
// delete the event handler from the hash table
if (element.events && element.events[type]) {
delete element.events[type][handler.$$guid];
}
}
};
function handleEvent(event) {
var returnValue = true;
// grab the event object (IE uses a global event object)
event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
// get a reference to the hash table of event handlers
var handlers = this.events[event.type];
// execute each event handler
for (var i in handlers) {
this.$$handleEvent = handlers[i];
if (this.$$handleEvent(event) === false) {
returnValue = false;
}
}
return returnValue;
};
function fixEvent(event) {
// add W3C standard event methods
event.preventDefault = fixEvent.preventDefault;
event.stopPropagation = fixEvent.stopPropagation;
return event;
};
fixEvent.preventDefault = function() {
this.returnValue = false;
};
fixEvent.stopPropagation = function() {
this.cancelBubble = true;
}
// Dean’s forEach: http://dean.edwards.name/base/forEach.js
// array-like enumeration
if (!Array.forEach) { // mozilla already supports this
Array.forEach = function(array, block, context) {
for (var i = 0; i < array.length; i++) {
block.call(context, array[i], i, array);
}
};
}
// generic enumeration
Function.prototype.forEach = function(object, block, context) {
for (var key in object) {
if (typeof this.prototype[key] == “undefined”) {
block.call(context, object[key], key, object);
}
}
};
// character enumeration
String.forEach = function(string, block, context) {
Array.forEach(string.split(“”), function(chr, index) {
block.call(context, chr, index, string);
});
};
// globally resolve forEach enumeration
var forEach = function(object, block, context) {
if (object) {
var resolve = Object; // default
if (object instanceof Function) {
// functions have a “length” property
resolve = Function;
} else if (object.forEach instanceof Function) {
// the object implements a custom forEach method so use that
object.forEach(block, context);
return;
} else if (typeof object == “string”) {
// the object is a string
resolve = String;
} else if (typeof object.length == “number”) {
// the object is array-like
resolve = Array;
}
resolve.forEach(object, block, context);
}
};
// showtable.jsp
<%@ page contentType=”text/html; charset=utf-8″ language=”java” import=”java.sql.*” errorPage=”" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;
%>
<style>
.highlighted { background-color:white; color:#06C;}
</style>
<script src=”<%=basePath%>scripts/sorttable.js”></script>
<script>
function check(loginform)
{
checkForm(loginform);
if(!checkForm(loginform))
{
document.getElementById(“displayError”).style.display=’block’;
}
}
</script>
<script type=”text/javascript”>
function ChangeColor(tableRow, highLight)
{
if (highLight)
{
tableRow.style.backgroundColor = ‘#99BCDC’;
}
else
{
tableRow.style.backgroundColor = ‘#577994′;
}
}
function DoNav(theUrl)
{
document.location.href = theUrl;
}
</script>
<div class=”tdscroll” id=”Height”>
<table width=”99%” border=”0″ align=”center” cellpadding=”3″ cellspacing=”1″ class=”sortable”>
<tr>
<td width=”12%” align=”center” class=”bg”><strong>Emp Id</strong></td>
<td width=”13%” align=”center” class=”bg”><strong>Emp Dept</strong></td>
<td width=”20%” align=”center” class=”bg”><strong>EMP NAME</strong></td>
<td width=”21%” align=”center” class=”bg”><strong>Email Id</strong></td>
<td width=”25%” align=”center” class=”bg”><strong>CONTACT NO.</strong></td>
<td width=”9%” align=”right” class=”bg”><strong>STATUS</strong></td>
</tr>
<%for(int i=0;i<20;i++){
String empid=”1004″;
%>
<tr onMouseOver=”ChangeColor(this, true);” onMouseOut=”ChangeColor(this, false);” onClick=”DoNav(‘showemp.jsp?id=<%= empid%>’);” style=”font-size:11px; text-align:left; background-color:#577994; padding-left:2px;”>
<td width=”12%”><%= i+1004%></td>
<td width=”13%”>HR DEPT</td>
<td width=”20%”>Employee Name</td>
<td width=”21%”>email@theinfindia.com</td>
<td width=”25%”>99999999</td>
<td width=”9%”>Approved</td>
</tr>
<%}%>
</table>
</div><script src=”<%=basePath%>scripts/searchable.js”></script>
Handle Property File in JAVA Application Programming
Using Property Files in JAVA (beginners Only)
Read data From Property FilesJAVA FILES
package com.secure.connection;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
import java.io.*;
import org.hibernate.validator.util.NewInstance;
/**
*
* @author AmishKumar
*/
public class ConnectDb {
private static boolean RETURN = false;
public static Connection con;
public static Statement stmt;
private static String path = poolingpropertydata.returnValue(“path”);
private static String dbname = poolingpropertydata.returnValue(“dbname”);
private static String dbuser = poolingpropertydata.returnValue(“dbuser”);
private static String dbpassword = poolingpropertydata.returnValue(“dbpassword”);
//path=”jdbc:mysql://localhost:3306/tiihms”
public static boolean connectToDb() {
boolean bool = false;
try {
Class.forName(poolingpropertydata.returnValue(“driver”)).newInstance();
con = DriverManager.getConnection(path, dbuser, dbpassword);
stmt=con.createStatement();
con.setAutoCommit(false);
bool = true;
} catch (Exception exp) {
bool = false;
exp.printStackTrace();
}
return bool;
}
}
MyProp.properties
path=jdbc:mysql://localhost:3306/
dbname=vlgt
dbuser=username
dbpassword=password
driver=org.gjt.mm.mysql.Driver
proxy=808
proxyip=127.0.0.1