10
Dec 08

Create a desktop shortcut to lock computer

You can lock your windows desktop by clicking on “windows key + L“. There is another way to do this. By creating a shortcut.

Right Click on your desktop and select

New -> Shortcut.

A shortcut will be created and a dialog box would pop up.

Copy paste %windir%\system32\rundll32.exe user32.dll,LockWorkStation into the text box of the dialog.

Click Next. Type any name you like.

A desktop shortcut with the name that you gave would be created. Double click anytime to lock your computer.


31
Jan 08

Exchange the value between two variables without using a temporary variable

Let me show you how you can interchange the values stored in two variables without using a temporary variable.

Case 1: For two integers

int a = 10;

int b = 20;

a = a+b;

b = a-b;

a = a-b;

Thats all!!! When you print the values stored in these two variables, you’ll notice that the values have been interchanged!

Case 2 : For two Strings

String s1 = “Shetty”;
String s2 = “Nischal”;

s1 = s1+s2;
s2 = s1.substring(0,s1.length()-s2.length());
s1 = s1.substring(s2.length());

System.out.println(“My name is “+s1+” “+s2);

The output will be: My name is Nischal Shetty


14
Jan 08

request.getParameterValues()

request.getParameterValues(String) in java helps retrieve a String array as parameter from the JSP.

i.e. If you have more than one value set for a variable in the JSP with the same name, you can get it as a String array using request.getParameterValues(“parameterName”)

Ex. in my jsp I set the variable as follows:

<input type=”hidden” name=”colour” value =”red”>

<input type=”hidden” name=”colour” value =”blue”>

<input type=”hidden” name=”colour” value =”green”>

Next, I try to obtain these values at the back-end java file as follows:

String colour[] = request.getParameterValues(“colour”);

All the three colours set in the JSP will be obtained in an array!!!