Get value of struts property tag into jsp variable

Hello friends when you work on Struts request property  then you can get the value of form by
<s:property value="a"/>
Same question arise by my friends :
Can anybody tell how to assign a value coming from "<s:property value="a">" into jsp variable ?
You can use the following to get the value in to variable
how to Get value of struts property tag into jsp variable,Get value of struts property tag into jsp variable,value of struts property tag into jsp variable,struts property tag into jsp variable,property tag into jsp variable,

For example there is a string avalue,
String avalue="";
Now you can assign a property value to it by using,
<s:property value="a"/>avalue=request.getAttribute("a");
above will gives the property value to a string variable. otherwise you can set the value and then assign it through getAttribute

How to convert number into word in java

What if someone asks you a java program for writing numbers in words .The problem with the question is that we dont know how big the input number can be. So first question we need to ask  what would be the range of the input. After getting the range , we can answer through algorithm or code of program.We provided two answers to this question as the countries like USA, UK uses million,billion,trillion terminology while Asian countries like India,Pakistan ,Srilanka uses lakh,crore,arab,kharab terminology.
How to convert number into word in java,convert number into word in java,number into word in java,word in java,

So lets find out the logic and java program for writing numbers in words.

public class NumberToWord  
    private static final String[] specialNames = {
        " thousand",
        " million",
        " billion",
        " trillion",
        " quadrillion",
        " quintillion"
    private static final String[] tensNames = {
        " ten",
        " twenty",
        " thirty",
        " fourty",
        " fifty",
        " sixty",
        " seventy",
        " eighty",
        " ninety"
    private static final String[] numNames = {
        " one",
        " two",
        " three",
        " four",
        " five",
        " six",
        " seven",
        " eight",
        " nine",
        " ten",
        " eleven",
        " twelve",
        " thirteen",
        " fourteen",
        " fifteen",
        " sixteen",
        " seventeen",
        " eighteen",
        " nineteen"
    private String convertLessThanOneThousand(int number) {
        String current;
        if (number % 100 < 20){
            current = numNames[number % 100];
            number /= 100;
        else {
            current = numNames[number % 10];
            number /= 10;
            current = tensNames[number % 10] + current;
            number /= 10;
        if (number == 0) return current;
        return numNames[number] + " hundred" + current;
    public String convert(int number) {

        if (number == 0) { return "zero"; }
        String prefix = "";
        if (number < 0) {
            number = -number;
            prefix = "negative";
        String current = "";
        int place = 0;
        do {
            int n = number % 1000;
            if (n != 0){
                String s = convertLessThanOneThousand(n);
                current = s + specialNames[place] + current;
            number /= 1000;
        } while (number > 0);
        return (prefix + current).trim();
    public static void main(String[] args) {
        NumberToWord obj = new NumberToWord();
        System.out.println("*** " + obj.convert(123456789));
        System.out.println("*** " + obj.convert(-55));

Logic behind this :
After thousand number , there is a symmetry in special names like million,billion,trillion,quadrillion,quintillion.
The symmetry is if you multiply 1000 with thousand than we will get a million. If we multiply 1000 with million then we will get billion. If we multiply 1000 with billion then we get trillion.Similarly,1000 multiply trillion equals quadrillion. 1000 multiply quadrillion equals quintillion.This symmetry starts after we reach 1000 number . So we will divide the program into two parts .
First part that is function convertLessThanOneThousand(int number) will convert any number smaller than 1000 into words.

Second part, starting from extreme-right of input number, we  will use modulus operator by1000, to get the last three extreme right digits of the input number.Taking three digits at a time from right to left , we will scan the whole input number until it is fully converted into the word.

How to Make KeyLogger in Java

Are you agree on statement "We can't create key logger in Java". I know most of you say this statement is correct. Because we know that Java can't read anything outside of JVM (Java Virtual Machine). Even I was thinking same but my colleague was searching on the same. He found API called jNativeHook which makes it happen..
Features of jNative Hook API

  1. Global Keyboard Listener
  2. Global Mouse Listener
  3. Global Mouse Wheel Listener
How it manage to capture key strokes from other application or anywhere in system?
How to Make KeyLogger in Java,Make KeyLogger in Java,KeyLogger in Java,how to create keylogger in java,create keylogger in java,java keylogger

Well jNativeHook using other programming language to capture key strokes and pass it to your application. Its using
  1. .dll (Dynamic Link Library) for windows.
  2. .dylib (Xcode Dynamic Library) for mac
  3. .so (Shared object) for linux
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;
 * @author javaQuery
 * Global Keyboard Listener
public class jNativeHookExample implements NativeKeyListener {

    /* Key Pressed */
    public void nativeKeyPressed(NativeKeyEvent e) {
        System.out.println("Key Pressed: " + NativeKeyEvent.getKeyText(e.getKeyCode()));

        /* Terminate program when one press ESCAPE */
        if (e.getKeyCode() == NativeKeyEvent.VK_ESCAPE) {

    /* Key Released */
    public void nativeKeyReleased(NativeKeyEvent e) {
        System.out.println("Key Released: " + NativeKeyEvent.getKeyText(e.getKeyCode()));

    /* I can't find any output from this call */
    public void nativeKeyTyped(NativeKeyEvent e) {
        System.out.println("Key Typed: " + e.getKeyText(e.getKeyCode()));

    public static void main(String[] args) {
        try {
            /* Register jNativeHook */
        } catch (NativeHookException ex) {
            /* Its error */
            System.err.println("There was a problem registering the native hook.");

        /* Construct the example object and initialze native hook. */
        GlobalScreen.getInstance().addNativeKeyListener(new jNativeHookExample());
Known Issues 

  • The library does not receive events after waking from a sleep state on Unix/Linux.
  • Users on Windows may experience a lapse in event data while using Remote Desktop in full screen mode.

Useful Links
Download API:

How to find Bluetooth device services in Java

Today I'm going to demonstrate "How to use BlueCove to search near by Bluetooth devices?" and "How to find Bluetooth device services in Java using BlueCove".
It is a Java library for Bluetooth (JSR-82 implementation) that currently interfaces with the Mac OS X, WIDCOMM, BlueSoleil and Microsoft Bluetooth stack found in Windows XP SP2 or Windows Vista and WIDCOMM and Microsoft Bluetooth stack on Windows Mobile.
How to find Bluetooth device services in Java,find Bluetooth device services in Java,Bluetooth device services in Java,device services in Java,services in Java,How to use BlueCove to search near by Bluetooth devices,BlueCove to search near by Bluetooth devices,search near by Bluetooth devices,search near by Bluetooth devices in java,

RemoteDeviceDiscovery class is used to find paired and near by devices.
import java.util.Enumeration;
import java.util.Vector;
import javax.bluetooth.DeviceClass;
import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.DiscoveryListener;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.RemoteDevice;
import javax.bluetooth.ServiceRecord;

public class RemoteDeviceDiscovery {

    public Vector getDevices() {
        /* Create Vector variable */
        final Vector devicesDiscovered = new Vector();
        try {
            final Object inquiryCompletedEvent = new Object();
            /* Clear Vector variable */

            /* Create an object of DiscoveryListener */
            DiscoveryListener listener = new DiscoveryListener() {

                public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
                    /* Get devices paired with system or in range(Without Pair) */

                public void inquiryCompleted(int discType) {
                    /* Notify thread when inquiry completed */
                    synchronized (inquiryCompletedEvent) {

                /* To find service on bluetooth */
                public void serviceSearchCompleted(int transID, int respCode) {

                /* To find service on bluetooth */
                public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {

            synchronized (inquiryCompletedEvent) {
                /* Start device discovery */
                boolean started = LocalDevice.getLocalDevice().getDiscoveryAgent().startInquiry(DiscoveryAgent.GIAC, listener);
                if (started) {
                    System.out.println("wait for device inquiry to complete...");
        } catch (Exception e) {
        /* Return list of devices */
        return devicesDiscovered;
ServicesSearch class used to find specific service on Bluetooth device. Each service identified using UUID (Universally unique identifier).
All UUID listed on .
Replace your required UUID in following code.
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.bluetooth.*;

public class ServicesSearch {

     * UUID used to find specific service supported by bluetooth device
     * Find UUIDs for all types of bluetooth services.
    /* To find push object service */
    private UUID OBEX_OBJECT_PUSH_PROFILE = new UUID(0x1105);
    /* To find file transfer service */
    private UUID OBEX_FILE_TRANSFER_PROFILE = new UUID(0x1106);
    /* To find hands free service */
    private UUID HANDS_FREE = new UUID(0x111E);
    /* Get URL attribute from bluetooth service */
    private int URL_ATTRIBUTE = 0X0100;
    public Map<String, List<String>> getBluetoothDevices() {        
         * Find service on bluetooth device 
         * Note: In following line you can use one service at a time. I'm new to bluetooth programming it might me wrong perception.
         * UUID[] searchUuidSet = new UUID[]{OBEX_FILE_TRANSGER_PROFILE};
         * CORRECT: UUID[] searchUuidSet = new UUID[]{OBEX_FILE_TRANSGER_PROFILE};
        /* Initialize UUID Array */
        UUID[] searchUuidSet = new UUID[]{HANDS_FREE};
        final Object serviceSearchCompletedEvent = new Object();
        int[] attrIDs = new int[]{URL_ATTRIBUTE};
        /* Create an object to get list of devices in range or paired */
        RemoteDeviceDiscovery remoteDeviceDiscovery = new RemoteDeviceDiscovery();
        /* Create map to return Bluetooth device address, name and URL */
        final Map<String, List<String>> mapReturnResult = new HashMap<String, List<String>>(); 

        try {
            /* Create an object of DiscoveryListener */
            DiscoveryListener listener = new DiscoveryListener() {

                /* To find bluetooth devices */
                public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {

                /* To find bluetooth devices */
                public void inquiryCompleted(int discType) {

                /* Find service URL of bluetooth device */
                public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
                    for (int i = 0; i < servRecord.length; i++) {
                        /* Find URL of bluetooth device */
                        String url = servRecord[i].getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
                        if (url == null) {
                        String temporaryString = "";
                        /* Get object of bluetooth device */
                        RemoteDevice rd = servRecord[i].getHostDevice();
                        /* Get attribute from ServiceRecord */
                        DataElement serviceName = servRecord[i].getAttributeValue(URL_ATTRIBUTE);
                        if (serviceName != null) {         
                            temporaryString = serviceName.getValue() + "\n" + url;
                            /* Put it in map */
                        } else {
                            temporaryString = "Uknown service \n" + url;
                            /* Put it in map */

                public void serviceSearchCompleted(int transID, int respCode) {
                    /* Notify thread when search completed */
                    synchronized (serviceSearchCompletedEvent) {

            /* Get list of bluetooth device from class RemoteDeviceDiscovery */
            for (Enumeration en = remoteDeviceDiscovery.getDevices().elements(); en.hasMoreElements();) {
                /* Get RemoteDevice object */
                RemoteDevice btDevice = (RemoteDevice) en.nextElement();
                /* Create list to return details */
                List<String> listDeviceDetails = new ArrayList<String>();
                try {
                    /* Add bluetooth device name and address in list */
                } catch (Exception e) {
                /* Put bluetooth device details in map */
                mapReturnResult.put(btDevice.getBluetoothAddress(), listDeviceDetails);
                synchronized (serviceSearchCompletedEvent) {
                    LocalDevice.getLocalDevice().getDiscoveryAgent().searchServices(attrIDs, searchUuidSet, btDevice, listener);
        } catch (Exception e) {
        /* Return bluetooth devices detail */
        return mapReturnResult;
BluetoothDevices is simple JFrame used to give Uter Interface for program. Its created in NetBeans IDE, You may find some code unexplained which is generated by IDE.
import com.javaquery.bluetooth.ServicesSearch;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.UIManager;

public class BluetoothDevices extends javax.swing.JFrame {

    /* DefaultListModel to attach it with JList */
    private DefaultListModel defaultModel;
    /* Map to get device details list */
    private Map<String, List<String>> mapReturnResult = new HashMap<String, List<String>>();
    /* Map to identify device on user click of JList */
    private Map<Integer, List<String>> mapDevicePosition = new HashMap<Integer, List<String>> ();

    public BluetoothDevices() {
        defaultModel = new DefaultListModel();

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        JListBluetoothDevices = new javax.swing.JList();
        lblDeviceName = new javax.swing.JLabel();
        lblRuntimeDeviceName = new javax.swing.JLabel();
        lblDeviceAddress = new javax.swing.JLabel();
        lblRuntimeDeviceAddress = new javax.swing.JLabel();
        lblServiceDetails = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        JTextAreaServiceDetails = new javax.swing.JTextArea();

        setTitle("Bluecove Bluetooth Discovery");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {

        JListBluetoothDevices.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {

        lblDeviceName.setText("Bluetooth Device Name");

        lblDeviceAddress.setText("Bluetooth Device Address");

        lblServiceDetails.setText("Service Details");


        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(73, 73, 73)
                            .addComponent(lblRuntimeDeviceName, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
                        .addComponent(jScrollPane2, 0, 0, Short.MAX_VALUE)))

    }// </editor-fold>//GEN-END:initComponents

 /* Search for bluetooth device when window opened */
    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        int intDevicePosition = 0;

        /* Create an object of ServicesSearch */
        ServicesSearch ss = new ServicesSearch();
        /* Get bluetooth device details */
        mapReturnResult = ss.getBluetoothDevices();

        /* Add devices in JList */
        for (Map.Entry<String, List<String>> entry : mapReturnResult.entrySet()) {            
            mapDevicePosition.put(intDevicePosition, entry.getValue());

 /* On click of any item in List Box */
    private void JListBluetoothDevicesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_JListBluetoothDevicesMouseClicked
  /* Get bluetooth device details from temporary list */
        List<String> tmpDeviceDetails = mapDevicePosition.get(JListBluetoothDevices.getSelectedIndex());
  /* Set bluetooth device name */
  /* Set bluetooth device Address */
        if(tmpDeviceDetails.size() > 2 && tmpDeviceDetails.get(2) != null){
   /* Set bluetooth device service name and URL */
            JTextAreaServiceDetails.setText("Service not found");

     * @param args the command line arguments
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                 /* To set new look and feel */
                try {
                     * Change look and feel of JFrame to Nimbus 
                     * For other look and feel check
                } catch (Exception ex) {
                /* Create an object of BluetoothDevices */
                BluetoothDevices bluetoothDevicesFrame = new BluetoothDevices();
                /* make BluetoothDevices visible */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JList JListBluetoothDevices;
    private javax.swing.JTextArea JTextAreaServiceDetails;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblDeviceAddress;
    private javax.swing.JLabel lblDeviceName;
    private javax.swing.JLabel lblRuntimeDeviceAddress;
    private javax.swing.JLabel lblRuntimeDeviceName;
    private javax.swing.JLabel lblServiceDetails;
    // End of variables declaration//GEN-END:variables

If you're fine then like and share that post.

What are Difference between load( ) vs get( ) in Hibernate

The following Hibernate code snippet retrieves a User object from the database:
What are Difference between load( ) vs get( ) in Hibernate,Difference between load( ) vs get( ) in Hibernate,between load( ) vs get( ) in Hibernate,load( ) vs get( ) in Hibernate,get( ) in Hibernate,


1). Only use the load()method if you are sure that the object exists.
2). load() method will throw an exception if the unique id is not found in the database.
3). load() just returns a proxy by default and database won’t be hit until the proxy is first invoked.

Session session = << Get session from SessionFactory >>
Long itemId = << Get the item id from request >>
   Item item = session.load(Item.class, itemId);
   Bid bid = new Bid();
} catch(ObjectNotFoundException e) {
   log.error("Bid placed for an unavailable item");
   // Handle the error condition appropriately

get( )

1). If you are not sure that the object exists, then use one of the get() methods.
2). get() method will return null if the unique id is not found in the database.
3). get() will hit the database immediately.

Session session = << Get session from SessionFactory >>
Long itemId = << Get the item id from request >>
Item item = (Item) session.get(Item.class, itemId);
if(item != null) {
   Bid bid = new Bid();
} else {
   log.error("Bid placed for an unavailable item");
   // Handle the error condition appropriately

Disadvantage of Hibernate

Hello java developer we all know the advantage of Hibernate but are you aware about disadvantage of Hibernate. If you want to use Hibernate in your program then focused on below statements.
The main disadvantages of Hibernate is given in detail.

1) Steep learning curve.
2) Use of Hibernate is an overhead for the applications which are :

  • simple and use one database that never change
  • need to put data to database tables, no further SQL queries
  • there are no objects which are mapped to two different tables

Disadvantage of Hibernate,hibarnate disadvantage

Hibernate increases extra layers and complexity. So for these types of applications JDBC is the best choice.
3) Support for Hibernate on Internet is not sufficient.
4) Anybody wanting to maintain application using Hibernate will need to know Hibernate.
5) For complex data, mapping from Object-to-tables and vise versa reduces performance and increases time of conversion.
6) Hibernate does not allow some type of queries which are supported by JDBC. For example It does not allow to insert multiple objects (persistent data) to same table using single query. Developer has to write separate query to insert each object.

Chromium WebView - Custom Android WebView

When we need a webview in android project. Then we can use webview but when we open our project on below of android version 4.4.x. Some functionality doesn't show on that webview.
And if you want to add the latest browser features in your old android version phone's webview or default browser.
Chromium WebView - Custom Android WebView,WebView - Custom Android WebView,Custom Android WebView,Android WebView,how to create own webview android,create own webview android,own webview android,webview android

Then answer is Chromium Webview
Are you amaze to hear that how can you make your own custom webview in android ?
You can give the power of google chrome in your old version android webview.
ChormeView works like Android's WebView, but is backed by the latest Chromium code. It lets you ship your own Chromium code, instead of using whatever version comes with your user's Android image. This gives your application early access to the newest features in Chromium, and removes the variability due to different WebView implementations in different versions of Android.
Chromium WebView - Custom Android WebView,WebView - Custom Android WebView,Custom Android WebView,Android WebView,how to create own webview android,create own webview android,own webview android,webview android,
How to setup this  chromium library :

  • Download the library code
First of all  download ChromeView library .
  • Make them library
After that Check out the repository in your Eclipse workspace, and make your project use ChromeView as a library. In Eclipse, right-click your project directory, select Properties, choose the Android category, and click on the Add button in the Library section.
  • Copy Data
Copy assets/webviewchromium.pak to your project's assets directory.
  • Initialize Chromium
Create new java file name MyApplication and initialize chromium

public class MyApplication extends Application {
    public void onCreate() {
Now you can use ChromeView in the same contexts as you would use WebView.
  • Use of ChromeView
in you main_activity.xml
We use instead of WebView like :
And in you 
ChromeView chromeView = ChromeView)findViewById(;
Note: Don't forget to give INTERNET PERMISSION .