Scenario In practical applications, when you create a profile (of a User or a Company say), you are required to maintain a picture or an icon to uniquely identify the entity so that every time the user or company visits the application, it finds the same picture which was last uploaded over the application. For Example, when a Facebook user uploads his picture, it is added to his photos list and every time he logs in, he can see the picture in that list. This can be done when you save the picture somewhere and retrieve it from there every time its required. A databaseRead More →

XML stands for eXtended Markup Language and is a widely used standard for transmitting information across systems mainly due to the flexibility it provides in creating the structure and data it can contain. That is, application developers can create their own structure which suits their application as there are no pre-defined tags in XML. Scenario Since it is a widely used standard, there arises a vital requirement to create an XML document either in the form of a String or a physical file from java application. Practical scenario isRead More →

An Exception is an undesirable state which arises out of some unexpected condition or scenario which was not handled during application development or due to some unexpected circumstances arising in the execution environment. Java provides support for handling exception conditions during application execution using try–catch blocks. Exceptions in java are categorized into two parts : Checked Exceptions Exceptions which need to be declared or handled during application development are checked exceptions. They are called checked because their appropriate handling is checked at compile time by the compiler. Handling implies either they are caught in a try-catch block or are declared to be thrown (using throwsRead More →

JDBC stands for Java DataBase Connectivity and is a technology for database connectivity from java program. JDBC is a collection of multiple interfaces and classes which provides methods for database connection and operations. Operations include executing SQL queries for fetching records, inserting and updating or deleting data from a database table directly from a java program. For performing any operation on a database using JDBC, requires some steps. They are :Read More →

A typical java application uses some values which are not suitable to be given in code such as log generation path, output location, configuration file path, timeout values etc. Since these values vary from system to system and user to user, their values can not be pre-fixed. One user may want his logs to be generated in “myLogs” folder, another user may want the logs to be generated in “appLogs” folder. If given in code, they cannot be changed without developer intervention. Further, this change would require a re-build of code.Read More →

hashcode() and equals() : Overview hashcode() and equals() methods are defined in java.lang.Object class which is the super class of all classes in java and hence may be overridden in any class. The signature of hashcode() method is public int hashCode() which means it should return an integer, and The signature of equals() method looks like public boolean equals(Object obj) which means it returns a boolean value indicating whether the object which called it is equal to the object which is passed as an argument to it or not.Read More →

It may happen that you need to add some days to a particular date and the resultant date is falling on either Saturday or Sunday. So you have to calculate the next working date. Practical Application : This is usually required in payments industry where the dates are written to files and these files are then uploaded to server but the server rejects the file if the date is a holiday. In such cases the date should be checked to be a holiday before writing it to file and incremented to a working day and then written to the file so that it is notRead More →

A web application developed using Java EE would definitely be using JSPs and would indeed involve transferring values from one JSP to another. For Example, a user is presented with a form where he fills the required details and presses a Next button where all those details are pre-filled in a non-editable form for him to confirm. The user checks the details to be correct and submits the form for further processing. The above scenario is pretty common and involves taking data from one JSP to another. This post addresses the approaches to achieve that.Read More →

Comparison between two dates is a task that every developer has to perform. Comparison implies determining which date is earlier or later of the two dates. It would be great if we are aware of different ways in which we can achieve it. Below are some of the ways for comparing two dates using java api classes and their methods.Read More →