Showing posts from July, 2005

What is a Transaction?

To illustrate the concept, let us assume that you want to transfer money from a savings account into a current account. In this scenario, it is critical that both the accounts are changed from a successful transaction and neither is affected from an unsuccessful one. You just cannot afford to have your money vaporize if crediting your current account fails for any reason after the debit on your savings account! Therefore, the most important concept that one has to be aware of when dealing with enterprise applications is the concept of a transaction. To a user, a transaction is a single change event that either happens or doesn't happen. Although this may sound like a fairly straightforward and simple requirement, it is hard to make this work in a distributed system without deploying some form of transaction control - computers can fail and messages can be easily lost.
Transactions provide a way to bundle a set of operations into an atomic execution unit. This atomic "all-or-no…

Do you have BRAIN?

Who Said English is easy?

Fill in the following blank with Yes or No -

______ I don't have a BRAIN.


GNU utilities for Win32

I have been using a W2K machine for the devlopment activities. However, sometime back I came acroos this set of tools that port some of the GNU Utilities to Win32 platform. Since then, I have been using them for various activities. Just check it out at

What is P3P?

P3P is the Platform for Privacy Preferences Project. It was developed by the W3C, (World Wide Web Consortium) as a protocol for providing automated privacy information to the end user, giving them more control over their own personal information at the web sites they visit.

P3P websites offer privacy information in a machine-readable format and P3P enabled browsers can read this and compare it to their own privacy standards. This protocol provides a standardization of privacy statements and presents it in a format that allows surfers to act on the information they are provided with.

The two main goals of implemented P3P policies are:

* To enable Web sites to present their data-collection practices in a standardized, computer-readable, easy-to-locate manner
* To enable Web users to understand what data will be collected by sites, how that data will be used, and what data and uses they may "opt-out" of or "opt-in" to.

How is it useful?

Web Applications usually uses cookie…

Common UNIX Commands

I just decied to look for a few commonly used UNIX command. A quick Google produces a lot more, but here are a list of more useful commands.

cd - Change Directory. (Just like in dos)mkdir - Make Directory.rmdir - Removes a Directory that is empty!ls - List directory. (Like dir in Windows)cat – Short for concatenate. It was used to concatenate two filestogether via cat file1 file2 >file3 Didn‘t know that did you. Theechoing out to standard out gave cat a whole new meaning to the users.more - Just like less. It pages output to the - Move. For moving files and directories aroundrm Remove a file. Also rm rf for removing a folder and it‘scontent.grep - Used to search for text within a stream or files. (man regex)vi – A text based editor. You‘ll find that it‘s really a symboliclink to vim now a days.rlogin - Remote login. I hope your admins disabled this!passwd - Used to change your - Used to processes.nice - Run a program with lower priority so you don't hog CPU…

What are the different type of JDBC drivers?

There are four types of JDBC database driver:

The JDBC/ODBC bridge driver (Type 1)A piece of native C-code that translates a JDBC call to an ODBC call. Use this driver for development, not for industrial-strength application environments. Note that you have to have an ODBC database driver manager + an ODBC database driver installed on the server in addition to the JDBC/ODBC bridge. Though useful for learning JDBC and quick testing, bridging solutions are rarely appropriate for production environments.

Native API partly java driver (Type 2)A piece of native C-code that translates a java JDBC call to a native database call level API. Use this driver for development and deployment. Due to its native code, this driver can only be used by Java Applications with full computer access (i.e. not Applets). Type 2 drivers generally provide the best performance, but they require the installation of native libraries on clients that need to access the database. Applications using Type 2 drivers have …

What’s the difference between Primary Key and Unique Key?

Both Primary & Unique keys are Indexes.

Index - An index is a structure in a table that orders the data. It allows the database to access data quickly (In MySQL its implemented using B-tree algorithms).

Primary Key - This is an index that cannot be NULL, Primary Keys are used in building relationships between tables in a database. (an index is automatically created on the primary key). The difference between primary and ordinary keys is that there can be multiple keys, but only one primary key.

Unique Key - Unique and Index are same, the difference is, in Unique, duplicate are not allowed in any circumstances and that is enforced by database server. Primary key(s) qualify to be Unique on basis of their uniqueness.
In case, your table has 2 primary keys means that the 2 fields together form one unique key. Each field by itself may have repeating values, but both primary keys combined together must be unique.

EMail Validation using Regular Expressions

Using Regular Expressions in Java, we can validate where the given email-id string is of the valid format. Here is a sample.

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public static boolean validateEmailId(String astrEmailId) {
//Set the email pattern string
Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
//Match the given string with the pattern
Matcher m = p.matcher(astrEmailId);
//check whether match is found
return m.matches();

RegExp can also be used in JavaScriptto validate EMail ID

function isEmail(str) {
// are regular expressions supported?
var supported = 0;
if (window.RegExp) {
var tempStr = "a";
var tempReg = new RegExp(tempStr);
if (tempReg.test(tempStr)) {
supported = 1;
if (!supported) {
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
var r1 = new RegExp("(@.*@)(\\.\\.)(@\\.)(^\\.)");
var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.


Here are a few of the pics of newly born nephew Shivam Garg, the youngest member of the Garg Family :)

How old are the daughters?

Two MIT math graduates bump into each other at Fairway on the upper west side. They hadn't seen each other in over 20 years.
The first grad says to the second: "how have you been?"
Second: "Great! I got married and I have three daughters now"
First: "Really? how old are they?"
Second: "Well, the product of their ages is 72, and the sum of their ages is the same as the number on that building over there.."
First: "Right, ok.. oh wait.. hmmmm.., I still don't know"
second: "Oh sorry, the oldest one just started to play the piano"
First: "Wonderful! my oldest is the same age!" Problem: How old are the daughters?

Improve the quality of your JMeter scripts has published an article on improving the quality of a JMeter Test Script. Just in case you are unaware, JMeter is an Open Source Load-Testing Tool from Apache. It has an excellent UI and various parameters and elements can be drag-and-dropped. []

Patterns: Inversion of Control

How do I make Tomcat startup faster?

These are a few of the options u can try to make your Tomcat Server startup faster:
Get a faster computer (:D) Make sure your code is not doing slow things. (Use a profiler like JProbe)Remove any jar files you don't need. When searching for classes every JAR file needs to be examined to find the needed class. Also during webapp startup, jar files are searched for TLD files. If the jar file is not there - there is nothing to search. Remove any webapps you don't need. (So remove the all the webapps installed with tomcat) Tweak memory parameters - Google is your friend. Trim the config files as much as possible. XML parsing is not cheap. The less there is to parse - the faster things will go.

How can I prevent my public JSP page from appearing within the search engine

There are two ways of achieving it: You can add a meta tag to the generated HTML content indicating that the page must not be indexed by the search engine's spider. <head>
<meta name="robots" content="noindex">
</head>put a file robots.txt at the root of your site, that is /robots.txt. In that file you can configure certain sections of your site to be skipped by crawling bots:# All robots will spider the domain
User-agent: *
Disallow: /path/of/files/or/documents/to/deny

How does session management work internally within the servlet en gine?

This very much depends on the servlet engine. Sometimes sessions are stored only in memory, in a HashSet of session IDs and the HttpSession. Some servlet engines support serializing session information to a file system or database, which allows the servlet engine to restart without losing session information, and to allow a cluster of web servers to use the same pool of sessions. Each servlet engine should provide details of the features of their session management. If you want to look at actual implementations, there are numerous open source projects including Tomcat (, and others.

Java SE 5.0: What's the difference between a StringBuffer and StringBuilder?

What's the difference between a StringBuffer and StringBuilder?

The StringBuilder class was introduced with JDK 5.0. Essentially, a StringBuffer is a thread-safe version of StringBuilder. If you are only adding/removing characters from a single-thread, the StringBuilder implementation will be faster. If you are using multiple threads to add and remove characters, use StringBuffer.

A Few IT definitions :-)

Project Manager is a Person who thinks Nine women can deliver a babyin One month.Developer is a Person who thinks a single woman cannot deliver a babyin nine months.Onsite Coordinator is one who thinks single woman can deliver ninebabies in one month.Client is one who knows that it takes a man, a woman & nine months todeliver a baby.Marketing manager is a person who thinks I can deliver a childwhether a man and woman is available or not.Resource optimisation team thinks I dont want man or woman, i'llstill produce a child with zero resources.Documentation team will think I dont care how a child is delivered,i'll just document 9 months.QA Auditor is the only person who is never happy with the PROCESS toproduce baby.