Monday, May 28, 2007

Eclipse Tomcat Integeration

In order to run servlet and jsp files within eclipse , you are provided with a internal browser and a tomcat plugin , that makes developing and testing easier.

The simple procedure to install the plugin and configure it to run servlets are given in the following link.

click here for more informations.

Thursday, May 24, 2007

Quote for the Day

He has the right to criticize who has the heart to help.

- Abraham Lincoln

Wednesday, May 23, 2007

Quote for the Day

If you are humble nothing will touch you, neither praise nor disgrace, because you know what you are.

- Mother Teresa

DHTML Drop Down Menu Bar

Hi guys,

Frustrated modifiying the css and javascript to create a menu bar from the existing one?

How about creating the one on your own , so that you can design it according to your needs?

Here is a link to a basic tutorial of creating it. Though its somewhat old , its quiet good for
startups .

Click Here for more information

Thursday, May 17, 2007

A man who describes words as his second language

Today i came to know about a man , for whom "Numbers are toys","Numbers has shapes",and "Numbers is everything".His name is Daniel Tammet.He is a savant.He is an autist.He is the boy with incredible brain.He is quiet interesting.After watching a video about him , i was very eager to know more about him as well as other savants in and around the world.

For video , http://video.stumbleupon.com/#p=i85su1w6uz

For more details about this guy , http://www.optimnem.co.uk/

Singleton Class

Have you ever come across a word or jargon called "Singleton" in java? if you had , and have no idea about it , here is a brief about Singleton Classes in java.

A singleton is an object that cannot be instantiated.It sounds contradictory to what we say "We need to instantiate an object before we can use it".So how can we create and use Singleton Classes? What is its advantages?

for clear precise information , Click Here

Mysql5.0 database import export

Recently i faced a issue of migrating a database and its content between MySql5.0 servers.In order to migrate i need to export the database contents from one server and import it into the other from the command prompt.This is how it is done.

To export:

In the command prompt go to the bin directory of MySql5.0,and enter the following command.


mysqldump --user="username" --password="userpassword" databasename>filename.sql


If you get an error saying access denied or something like that, replace your username with the default one(root) in the above command .

Thats it , you will get a .sql file in the bin directory with the name mentioned in the command line.

To import:

In order to import , place that .sql file in the bin directory of the other MySql5.0 and enter the following command.


mysql --user="username" --password="userpassword" databasename < filename.sql


Thats it. But do remember to create a database with the name you specify in the command line.

Tuesday, May 8, 2007

Chained Exception

It is the process in which a exception causes another exception with the original cause attached and the chain of exceptions is thrown up to the next higher level exception handler.

For example


try
{

}
catch (IOException e)
{
throw new SampleException("Other IOException", e);
}




The following are the methods and constructors in Throwable that support chained exceptions.

Throwable getCause()
Throwable initCause(Throwable)
Throwable(String, Throwable)
Throwable(Throwable)

Exception Example


try
{

This is where your logic goes like Opening a file
reading a file closing a file,etc

}
catch(FileNotFoundException ff)
{

This gets executed when the expected file is not found

}
catch(IOException ie)
{

This gets executed when the read or write operation failed

}
finally
{

This always executes when the try block exits.The finally block is a key tool for preventing resource leaks. When closing a file or otherwise recovering resources, place the code in a finally block to insure that resource is always recovered.

}



So far we have seen scenarios where it's appropriate for code to catch exceptions
that can occur within it.In some cases, however, it's better to let a method further
up the call stack handle the exception.In this case, it's better to not catch the
exception and to allow a method further up the call stack to handle it.

This can be done by modifying the method to specify the exceptions it can throw ,
instead of catching them.

For example


public void methodName() throws IOException{}


Java provides numerous classes of exception.All the exception classes are descendant
of Throwable class.

User can create his own exception class by extending the Throwable class. Java
doesnot provide any interfaces for creating exception classes.

Types of Exception

In java there are two types of exceptions.

* Checked Exceptions
* Unchecked Exceptions.

Unchecked are further classifieds into

>> Error
>> Runtime Exceptions

* Checked Exceptions

These are exceptional conditions that a well-written application should anticipate and recover from.

For example java.io.FileNotFoundException.

All exceptions are checked exceptions, except for those indicated by Error,
RuntimeException, and their subclasses.

* Error

These are exceptional conditions that are external to the application, and that the application usually cannot anticipate or recover from.

For example java.io.IOError

* Runtime Exceptions

These are exceptional conditions that are internal to the application, and that the application usually cannot anticipate or recover from.These usually indicate programming bugs, such as logic errors or improper use of an API.

For example NullPointerException,Division by Zero , etc.

Exceptions in Java

An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions.

When a exception occurs , the system searches for a block of code called "Exception Handler" in the call stack.

Call Stack is nothing but the list of methods that had been called to the method where the exception occured.

The system searches for the appropriate method in the call stack in the reverse order . If the appropriate method is found , the exceptions are handled , else the system terminates.

The block of code that is expected to throw some exception is written in
try.....catch....finally block.

Friday, May 4, 2007

Turning a Negative into a Positive

As the title implies , its all about how can a change in attitude or character can bring in a turning point to your life in all aspects.These are so small , yet the results are so big that it becomes necessary in everyones life. Its all about "Avoiding destructive comments about other people or groups".It does not matter whether its being done in front of them or at the back. Just avoid it. As we have heared "The best thing to do at ones back is , just pat them".

For details Click Here