Singleton Pattern in Java

Hello Friends, This is one of my tutorials on java Design Patterns. Java has several design patterns Singleton Pattern being the most commonly used. Java Singleton pattern belongs to the family of design patterns that deals with More »

Convert String to XML file in Java.

Hello Friends, In the previous example we have seen how to convert XMl to String. Now this example will do the exact opposite of the previous one i.e. we will now try More »

Convert XML file to String Object in Java.

Hello Friends, This is one of my tutorials in java with respect to XML. Sometimes while working with web-services we may come accross with the requirements of sending the updates to the More »

Login Example: JSP and Servlets: Part III.

Hello Friends, This is Part III of this tutorials. Check Part I and Part II here. Step 8 ) We are done with the DAOs and Beans. Now we need to create More »

Login Example – JSP and Servlets: Part I.

Hello Friends, This is one of the tutorials on JSP and Servlets. In this we will discuss and create a simple login application using servlets and JSP where we will connect to More »

Redirecting to JSP page from a Servlet.

Hello Friends, This tutorial is regarding the redirection from the Servlet page to a another jsp page. Most of you may need to redirect the user to a jsp page being on More »

Servlet program using Eclipse IDE.

Hello Friends, This tutorial is regarding development of Servlet applications on Eclipse IDE. Eclipse IDE is very popularly used for development of various web based and java applications. Servlet applications are very More »

Write to html file in java.

Hello Friends,

This is one of the tutorials to write to html file in java using I/O api. This is very simple, and can be done in the same manner as for any other file. You just need to create a file with .html extension and when you are writing the data into the BufferedReader object then you need to add the html attributes and normal html code. Lets check the below example.

Core Java Interview Questions – Part III

Continuing with the previous post on java interview questions.

  • What is JIT compiler?

Ans :- Just In Time compiler is used to improve the performance. It compiles parts of byte code that has similar functionality at the same time and hence reduces the amount of time needed for compilation.

Reflection in Java : Access private method from outside the class.

Hello Friends,

This is one of the interesting tutorial regarding Reflection in java. We know that any method which is declared private cannot be accessed by other class. However, reflection allows to access private method from outside the class. Lets see the example below.

User Registration with Email Confirmation : Part III.

The registration with email confirmation part III continues from part II.

To identify which servlet to call, we have to define the url mapping for each of the servlet. The RegisterServlet mapping is added in the web.xml file. Apart from this, servlet mapping for confirmation of user is also added in the same, we will see what actually ConfirmtionServlet consists of in later part.

User Registration with Email Confirmation : Part II.

Lets continue with where we left Part I. This is part two of registration with email confirmation.

Now we have to create a DAO layer to insert the user details in the DB. Here I have updated the LoginDAO which was used earlier only for login purpose, now this will contain the method to insert the new user details. The new LoginDAO will be as-

User Registration with Email Confirmation : Part I.

Hello Friends,

This is one of the tutorials regarding Login Application. The example will guide you through the process of user registration with email confirmation on your site, the email confirmation is necessary now a days to authenticate and verify the user. The email contains the details of registration and a link to activate the account, unless which he/she cannot login. This tutorial uses the example which we already used in Login Example.

Core Java Interview Questions – Part II

Continuing with the previous post.

  • What are the hashcode() and equals() methods used to?

Ans:- These methods are used to identify the uniqueness of any object. An Object is said to be unique with other, only if its hash code is same and its equals method return true i.e. object1.equals(object2) returns true. Note that, if the hash code  of any two objects are equal, it does not mean the objects are equal.

Core Java Interview Questions – Part I

Hello Friends,

Below are some of the important core java interview questions that may be asked to you while interviewing on Java. Going through this post will really help you. There are around 50 questions that I have collected from various places and from my personal experience as well. Lets start from basics-

Sorting Array of 1s and 0s.

Hello Friends,

This is one of the common but tricky questions asked in the core java interview, how you can sort the array of 1′s and 0′s in the sorted order, i.e. all the 0′s should come first followed by all the 1′s. At this point, you will be thinking whats difficult in this? We have collections and its sorting method, so we can easily do so.

Sorting Map in java.

Hello friends,

Just came across a scenario, where I need to display the result of the map in ascending order. I need the value of the keys to be displayed/populated in the specific order. So whats the big deal in it, right? Yes. But the thing here is, my Map is of type <String, Object>, this object may be anything user defined. If this type of the value in the map was any predefined object like String, Integer, etc.. then it would have been easier for me to sort those values, but this case is different. However, i got the workaround on it, and wanted to share it with you all. Hope this will help many of the needful, like me ;) .