There are scenarios where we want to take some actions before a bean is fully constructed and put into service such as giving a specific name to the bean other than that given in the configuration, setting the application context into a bean property, making a log entry immediately after bean initialization etc.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 →

There are many operations which we have to perform on select boxes (or drop downs) such as selecting an option based on index, selecting an option based on visible text, removing an option etc. using jQuery. Most of the times, we do not remember the selectors or methods to accomplish the required task and we end up searching the Internet giving away our valuable time. In this post, I have tried to accumulate various operations and their methods which should be helpful to many. Read On !!!Read More →

Scenario Suppose we want to show a list of registered users of the application in a tabular format on a jsp. The list of users is created on the server and is bound to an attribute (in request, session or application scope) if you are using servlet or bound to an attribute in ModelAndView if you are using Spring controller as below.Read 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 →

Overall notion of Singleton class lies in getting one and only one instance of the class. Much of our functionality relies on the base that there will be only one object of a class we intentionally designed to be Singleton. What if the same class produces more than one object in some scenario? Woaaah!!! Our code blows away.Read More →

Sort list of objects on a field Suppose you have a list which contains objects of your own class rather than java’s built in classes such as java.lang.Integer, java.lang.String etc. Now you want this list to be sorted on a particular field of this class. Let’s say we have a User class which contains user details such as name, age, address etc., and we have a list of various users. Now we want a list wherein users are listed in the order of their increasing age. That is, we need to sort the above list in the order of age. Collections.sort method You can sortRead More →