• Enter Slide 1 Title Here

    This is slide 1 description. Go to Edit HTML of your blogger blog. Find these sentences. You can replace these sentences with your own words.

  • Enter Slide 2 Title Here

    This is slide 2 description. Go to Edit HTML of your blogger blog. Find these sentences. You can replace these sentences with your own words.

  • Enter Slide 3 Title Here

    This is slide 3 description. Go to Edit HTML of your blogger blog. Find these sentences. You can replace these sentences with your own words.

Friday, April 27, 2007

Google Adsense gets nice look and feel with Google Account

Seems Google has started integrating Google Adsense with Google Account. We believe this as a good step since it makes life easier, login to only one account but have many services working. Previously Google did this with Blogger as well. New login page is very nice and colorful. New login page looks as below.


Currently the two old and new login pages can be accessed using two different URLs, but this will be changed very soon.
Old login page: www.google.com/adsense/login3
New login page: www.google.com/adsense/login/

Wednesday, April 25, 2007

Sri Lanka through to World cup finals playing against 11 or 13?

Today is a special day for Sri Lankans as SL made their way to finals in World Cup 2007 after the semi final victory over New Zealand yesterday. That was a fantastic match even though it was hard to judge whether SL were playing against 13, not just 11 players. SL was playing against 11 friendly and claim NZ players (and 2 slightly unfair professional umpires).

Interesting point was both the 2 umpires, RE Koertzen (South Africa) and SJA Taufel (Australia) made poor LBW decisions against SL. One LBW was given for a thick edge and the other for a ball going far away from the leg stump. When NZs were batting, umpire RE Koertzen warned Dilhara twice putting him under huge pressure. Another a tough LBW decision was given against Rose Tailer for a ball slightly missing the stumps. We can not guess why such experienced umpires give that much bad decisions in crucial matches like semi finals.

Even with that type of a situation, SL team came up brilliantly in batting, balling as well as fielding. NZ got the wicket of SL inform batsman Sanath Jayasuriya pretty early putting SL under pressure. But SL came back strongly with Upul Tharanga's 70 followed by the superb captains knock of 115* by Mahela Jayawardana. SL scored over 100 runs in the last 10 overs. In the NZ innings, it was just a series of perfect bowling to get them all out for 208 runs. My deepest sympathies to all the New Zealanders.

We were discussing about the match here (before the match). Congratulations Sri Lanka and all the very best wishes for the coming finals to bring the World Cup here again.

Sunday, April 22, 2007

World Cup Semi final on 24th: Sri Lanka vs New Zealands

Tomorrow (2007-04-24) is going to be a big big day for both Sri Lanka and New Zealand. Two teams meet each other in a crucial match, semi finals. In recent past, SL have done well against New Zealand. They once met in the super eight matches and Sri Lanka won comprehensively by 6 wickets.

According to news, the pitch at Sabina Park in Jamaica will have some bounce. This is said to be favoring NZs because SLs have much experiences on subcontinent wickets. But having the best balling department, SLs will be able to get the benefit of the bounce as well.

A quick comparison over the two teams

1. Captaincy:
Stephen Fleming, the New Zealand captain has more experience and is a good leading captain. But Mahela Jayawardane is one of the best positive captains in the world who has shown much colors in a lesser number of matches. So I weight SL has a good captaincy.

2. Balling attack:
NZ comes with one of the best ballers in the world, Shane Bond. But SL goes with 4 high class ballers: Vaas, Murali, Sanath and impressive Malinga. So SL has a huge advantage.

3. Batting:
NZ has a good batting line up starting with their captain, Fleming and following with Oram, Styris, McMillan and McCullum. SL comes with Sanath Jayasuriya (World's best batsman who frightens the opposite), following Sangakkara, Mahela, Chamara and Dilshan. So seems both have good batting attack. But it's a matter of getting some of them to show their class.

4. Fielding:
NZ is doing well of fielding, but they are not up to the level as much as SL. SL are putting huge pressure on the opposition by a showing a good team effort at the ground.

These are some comparisons, but the team that play as one unit and perform best will defeat the other. This is the first time NZ plays for a semi final in a world cup. So it will be a huge game for them.

But still I believe SL will beat NZ and go for the big final on 28th.

All the best wishes for SL from me and all the SL lovers. (Hope you are also joining with me to wish SL).

Tuesday, April 17, 2007

Open and read any file in a .war file of a web application with Java

Question: How can I open and read a file inside a war file of a web application?



Answer: InputStream can be used for this with a ClassLoader.




A code snippet for opening a file from Java for reading a file inside a web application is listed below. Commented line (InputStream inputStream = new FileInputStream(filePath);) shows the common approach used in non-web applications. Common approach is not usable with web applications (.war file) since it fails to find the files. Even though the correct relative path is provided, programs will face issues depending on the web server versions.





For web applications, the InputStream will be created using a ClassLoader. Following code snippet can be used for this requirement. But this approach has one limitation. This can read only the files inside WEB-INF/classes folder.
import java.io.InputStream;

public class WebAppFileReader {

public static void main(String[] args) throws Exception {

// full path: "C://projects//myWeb//WebRoot//WEB-INF//classes//testFile.txt";

String filePath = "testFile.txt";



// InputStream inputStream = new FileInputStream(filePath);

InputStream inputStream = WebAppFileReader.class.getClassLoader()

.getResourceAsStream(filePath);


int size = 10;

byte chars[] = new byte[size];

inputStream.read(chars);

String str = "";

for (int i = 0; i < size; i++) {

str += (char) chars[i];

}

System.out.println(str);

....

}

}


Note that only one change has to be made to make it read the files inside a web application. This is highlighted below.

1. InputStream inputStream = new FileInputStream(filePath);

2. InputStream inputStream = WebAppFileReader.class.getClassLoader()

.getResourceAsStream(filePath);



By replacing line #1 with #2, a class to read files of a web application is created. One important point to note is: WebAppFileReader is the name of the class in which these codes will be written. So if a different class is used with these code snippet, keep in mind to alter this line and add the class name of that.



Hope this will help you.

Friday, April 6, 2007

Cricket: Sri Lanka won by two runs over England in World Cup 2007


Sri Lanka vs England super 8 match was on 2007-04-04. They played an amazing match, it was the best game so far in this World Cup. Even that was one of the greatest matches I ever had watched.

Sri Lankans were all out for just 235 runs causing many discussions to calculate how many runs should have been added to make it a winnable score. Then England started batting, but they were 12/2 after 6 overs.

Over 20: Englands were in a comfortable situation, 100/2 with a RRR(required run rate) of 5.4. But this was easily reachable as Pietersen was batting impressively putting Sri Lankans under pressure.

Over 34: Pressure on Englands. They were 134/6, with a RRR of 6.4. And Sri Lankans needed only one wicket two celebrate the tail enders' fun. And England fans were dead silent.

Over 46: But that required wicket didn't fell and England batsman were rotating the strike well and they were 217/6 with a RRR of 9.5. But this was easily reachable as both the batsman were well established. It was just 19 runs from 12 balls.

Sri Lankans were under huge pressure, two more overs to go. Who should ball the late two overs?

Over 49: Lasith Malinga called for the 49th over. Big task for young Malinga.
1 1 0 1 W 4
This is a fantastic over. Malinga got the needed break through, but the last ball went for a four.

Over 50: Last over, 6 balls more to go, needs 12 runs. Who should ball the last 6 balls? Chaminda Vaas had two more overs, Sanath Jayasuriya had two more... No no it was Dilhara Fernando to ball the last over.
49.1 - 1 run
49.2 - 4 runs
49.3 - 2
49.4 - 1
49.5 - 1

Just 3 runs from the last ball, the well set batsman Bopara was facing. Dilhara came to ball the last ball, but stopped at the last second. Crowd get confused!!! He came back again, and balled him!
Oh! Dilhara balled him! Can you believe it? Sri Lanka won the match just by 2 runs.

What a fantastic game? You should have watched it.

Congratulations Sri Lanka.

Wednesday, March 28, 2007

Yahoo! Mail provides unlimited storage

Yahoo has made a big announcement. They are going to provide unlimited storage for Yahoo Mail!!! This huge feature will go live from May 2007. Can you believe it? Are they really going to achieve this or is this going to be an April Fool's Day Joke? Can't be. Today is 28th of March.

In April 2004, Google launched GMail, with a 1GB which made all of us shocked, while Yahoo Mail providing 100MB storage. This caused the huge popularity of GMail. So many people switched to GMail from Yahoo and MSN (including me). In fact Google came up with a nice concept of expanding the user's storage limit every second and showing it in GMail home page. Currently it shows 2833.807851 on my machine.

Yahoo Mail expanded in following fashion.
1997: 4MB
2004: 100MB
2005: 1GB
2007: Unlimited storage
But I really don't think that people love GMail just because it provides 2GM+ storage, but because of the features that it provides. So while providing huge capacities, Yahoo Mail will have to provide great and new features to fight the battle. And also users (like me) are not looking for unlimited storage as it tends to become more harder to find some of the important mails from the millions of emails in the mail box. So better to come up with new useful features to win the battle.

Now Yahoo Mail has announced the big event and it's up to them to keep their word. I don't think it'll be easy for them to provide infinite storage, as within 2-3 years the total storage requirement would be huge in number. They will have to come up with some strategy to limit the storage capacity for individual users.

[JSTL] According to TLD or attribute directive in tag file, attribute items does not accept any expressions

Error Message: According to TLD or attribute directive in tag file, attribute items does not accept any expressions. When working on a J2EE (Java Enterprise Edition) web application with JSTL (JSP Standard Tag Library), this is a pretty common error.

Reason for this error is version incompatibility between JSP, Servlet and JSTL. Matching versions are listed below.
  • JSP 1.2 , Servlet 2.3 , JSTL 1.0
  • JSP 2.0 , Servlet 2.4 , JSTL 1.1

Check the web.xml to see whether it uses the Servlet 2.3 DTD or Servlet 2.4 Schema.

If it uses Servlet 2.3 DTD, it will have the following text.
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
.....
</web-app>

For Servlet 2.4 Schema, it will look like below.
<web-app version="2.4" 
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
.....
</web-app>

When you change the versions correctly, no such errors will pop-up. Hope this will help you.

Wednesday, March 21, 2007

A child born, two years after his father's death

According to your maths, above subject would not be correct. But that has happened in Texas. As CNN reports, the little boy's name is Benton Smith and his brave and courageous mom is Kathleen Smith while father was Brian.

Brian, who was a solder in US army has gone for Iraq in 2004, and died there in July - 2004. But his wife has given birth to a boy in July, 2006. This has happened because Brian had donated his sperm so Kathleen could keep trying to have a baby while he was in Iraq.

Congratulations Kathleen. You are a great mom and a great wife.

Read more at CNN.com

Monday, March 19, 2007

[Cricket] World record - Six sixes in one over

Herschelle Gibbs, 34 yrs South African right hand batsman made a big record on 2007-03-16. He did this against a leg-spinner, Daan van Bunge of Netherlands in the 30th over.

This is where those bullets went.
29.1 : long on
29.2 : long off
29.3 : long on
29.4 : deep midwicket
29.5 : wide long off
29.6 : deep midwicket
Gibbs got 72 off 40 balls with 7 sixes before Van Bunge caught him in the next over at long on.

West Indies great Sir Garfield Sobers and India's Ravi Shastri had done this six sixes in one over during first-class matches. But this is the first time in an international match.

Congratulations Gibbs.

Related:
World record test cricket partnership

Friday, March 16, 2007

Decipher the code to check your eyes

Try to read the following code. Even though this image looks like an ordinary one, it has a hidden message. But you won't be able to read it if you have good eyes.


Couldn't you read that? You can see the answer below but try it again if you could not. Don't directly go and see the answer. Don't show that you have bad eyes. Try again.

To see the answer click here.


Tuesday, March 13, 2007

Cartridge World operations automated using NetSuite - With my implementations

Today is a pretty happy day in my life as one of the projects implemented by me has received a good reputation with this article by Yahoo! Finance.

Basically the requirement was to integrate two systems, so that Cartridge World can use the full blown features of NetSuite. This integration is implemented by me with the coordination and help of my CEO and other members at Celigo Technologies. I'm proud to be part of a success story.

Cartridge World, is a world's fastest growing ink refilling retailer in printer cartridge industry. NetSuite, is a leader in on-demand business software suites. Cartridge World wanted to use NetSuite system to automate their e-commerce operations and it is implemented throw integrations with Java. The article shows how far the project succeeded.