Saturday, February 27, 2010

ThreadLocal Example in Java

To share a some object associated or linked with 1 thread at any point of time and do not want to modify this value by any other thread then ThreadLoal is useful.This also avoids no need to think about synchrniation,because each thread maintain's it's own copy.

public class ThreadLocalExample extends Thread {

private static int nextSerialNum = 0;
private static ThreadLocal serialNum = new ThreadLocal() {
protected synchronized Object initialValue() {
return new Integer(nextSerialNum++);

public static int get() {
return ((Integer) (serialNum.get())).intValue();

public void run() {
for(int i=1;i<30;i++)
    System.out.println("Name : " + Thread.currentThread().getName() +" Value : " + get());

  public static void main(String[] args) {
    Thread t1 = new ThreadLocalExample();
    Thread t2 = new ThreadLocalExample();
    Thread t3=new ThreadLocalExample();

For more information on ThreadLocal class usage

To understand this concept more clearly execute the above program and observe the output.

Monday, February 22, 2010

Struts Layout Tree View Example

Struts Layout provide so many features for Struts developers,
so if you want to know about more information on struts-layout visit

To know about what the features are there in practical some programming example requried.

To download struts layout tree view example click any of the bellow links
Mediafire  :

how to read excel file in java

To read Excel file in java using Jakarta POI  (or) JExcel API  visit the following url

To download POI Jar file Click Here

Sunday, February 21, 2010

How to Write and Read Some Content into (or from) File Using Java Script

To write some content into some file or read content from file and wants to store all file content in one variable and wants to dispaly this as a alert or some thing the following program will be helpful.This works in Internet Explorer.


<SCRIPT language="JavaScript">

function WriteAndReadFile()


var fso = new ActiveXObject("Scripting.FileSystemObject");

var fh = fso.CreateTextFile("D:\\Test.txt", true);

fh.WriteLine("Text Example 1");

fh.WriteLine("Text Example 2");

fh.WriteLine("Text Example 3");

var f;

var str;

f = fso.OpenTextFile("D:\\Test.txt", 1);

var s=f.ReadAll();








<SCRIPT language="JavaScript"> WriteAndReadFile(); </SCRIPT>




Turbo C Software Free Download

To download Turbo C Software from official web site that you have to register and then you are able to download freely.

To install C software in Your Windows Operating System copy all Disk2,Disk3 files individually into Disk1 and click install.exe present in your Disk1 which came with your downloaded Zip file.
Simply Click Here to Download

Ajax Tag Library for Server Side Java Applications

Ajax Tag Library from is good to reduce the maintenance cost of our project developed in servlets,jsp or struts.To know more about this ajax tag library from sourceforge Click Here.

Thursday, February 4, 2010

How to Open Notepad through HTML File

The following program will launch the Notepad by Pressing button in web browser.This works in Internet Explorer only.

<script language="JavaScript" type="text/javascript">
function runReport()
var rep = new ActiveXObject("WScript.Shell");
rep.Run("C:\\Windows\\system32\\notepad.exe", 1, true);

<h1>Run a Program</h1>
This script launch the file >> c:\windows\system32\notepad.exe<p>
<button onclick="runReport()">Run Windows NotePad</button>