Monday, October 6, 2008

Check java version:

Try this to check the version:

    javac -version           java -version

For javac, if you aren't on 1.5, the -version won't work.
You can use
    javac -J-version

in any version

That will cause javac to pass -version when it invokes java, which will tell you the VM version, but not the javac version.
The two will usually be in sync, though--I'm just being a pedantic ballsniffer.

Tuesday, July 22, 2008

Jcavaj: Nice Java Decompiler

Jcavaj - Nice java decompiler.
This lets you see the java source code out of .jar file. (The source code need not exist in your system. A nice hack ;)
 

Thursday, June 26, 2008

Mozilla 2.0.0 bug

The code below, opens up two windows of 'test2.html' if you click on the button, where as clicking on  link, it will open only one.
 
"..
 
This is test.html<BR>
<a href="test2.html" target="_new" alt="go to test2">
 Go to test2<input type="button" name="pButton" value="goto test2"/>
</a>
.."
 
This may be a bug in Mozilla 2.0.0.
The same works correctly (opens up only one window) in firefox 3.
 
 

Thursday, April 24, 2008

Preventing Duplicate Record Insertion on Page Refresh

A Nice article from Terri Morton on " Form resubmission upon browser refresh "
 

Tuesday, March 18, 2008

proper close of JDBC Connection

Wrong way to close the connection object:
 
        Connection con = ds.getConnection();
         ....
         ....
         ....
         con = null;
 
Right way:
    Connection con = ds.getConnection();
      .....
      .....
      .....
      con.close();
      con = null;
 
 

Thursday, February 14, 2008

Dynamo doStartService()

ATGDynamo:
  This method will be called automatically at the time of component load..
   " public void doStartService() throws ServiceException "
 
  where as
    " public void doStartService(<argtype> <argname>) "
 
  wont..
 
 

Thursday, February 7, 2008

Java Trick : null in string comparison

String str = "null";
 
 
if ( str == "null") {
 System.out.println(" String value is 'null');
} else {
   System.out.println(" String value is not 'null');
}
 
Output:  " String value not 'null' "
 
if ( "null".equals(str)) {
 System.out.println(" String value is 'null');
} else {
   System.out.println(" String value is not 'null');
}
 
Output:  " String value 'null' "
 

Wednesday, January 16, 2008

Thursday, January 10, 2008

Heredoc Syntax

Because I always forget...
 

Perl heredoc syntax:
$var = <<EOF;
    text goes here
EOF
 
PHP heredoc syntax:
<?php
$str = <<<EOF
text goes here
EOF;
?>
 

Ruby heredoc syntax:
str = <<EOF
  text goes here
EOF
 
Python:
str = """text goes here
"""
(text is on the same line as the """ for parity with the other examples)

Wednesday, January 9, 2008

JavaScript Tip


Javascript to accept only numbers:

var isNS4 = (navigator.appName=="Netscape")?1:0;

<textarea rows=2 cols=20 name=comments onKeypress="if(!isNS4){if ((event.keyCode > 32 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 65) || (event.keyCode > 90 && event.keyCode < 97)) event.returnValue = false;}else{if ((event.which > 32 && event.which < 48) || ( event.which > 57 && event.which < 65) || (event.which > 90 && event.which < 97)) return false;}"></textarea>


ASCII values for keys:

numpad
  DOT/DECIMAL  ('.') : 110
  NUMBERS:  0 - 9 =  96 - 105

KEYBOARD
DOT/DECIMAL/PERIOD  ('.') :  190
NUMBERS:   0 - 9 = 48 - 57


CSS support in browsers

This is a good matrix which shows, browser compatibility with CSS.

http://www.westciv.com/style_master/academy/browser_support/index.html