How to convert XML file to java objects / Converting XML file to java objects using JAXB

Practical Scenario

Suppose your application has to read an XML file and store its contents in a database such as each set of nodes is created as a record. For Example, there are multiple employee nodes with employee details in your xml and you have to store each employee details as a record in database. The process would be pretty easy if you have some mechanism to get the employee details form the XML in the form of java objects as then you could iterate those objects and store them by using JDBC or directly save them using any ORM framework (such as Hibernate). (more…)

Continue Reading

How to create XML from java objects / Create XML from objects using JAXB

Scenario

Suppose your application fetches a record from a database and it needs to create an XML out of it. There are chances that your application uses an ORM framework such as Hibernate and the database record is fetched in the form of entity classes. Now you have two ways, iterate over the object properties and create each XML node manually using the XML DOM apis (How to create XML from Java program using DOM parser) or follow the approach detailed here. (more…)

Continue Reading

JDBC Vs Hibernate – A Comparison / Difference between JDBC and Hibernate

JDBC is an acronym for Java DataBase Connectivity and is a technology for interaction of java application and its objects with a database. Hibernate on the other hand is a java based framework which also facilitates the interaction of application objects with a database but in a completely different approach.

Below are listed some differences between the two. The points do not intend to indicate which is better, they just compare the various aspects of the method of operation of both. The headers before each row indicate the area of comparison. (more…)

Continue Reading

How to iterate over a list of objects in jsp / How to create a table from a list of objects in jsp / How to iterate over a collection using jstl

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. (more…)

Continue Reading

How to send data from one JSP page to another

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. (more…)

Continue Reading
Close Menu