Servlet is a one the most famous web technology till date. It was the first successful and heavily consumed web technology for Java. Since then new technologies have come but the glory remains the same for the Java Servlets. Servlets are very useful for understanding the latest trend of programming and for certain use cases.
This is a continuation of our previous article Servlet Introduction. if you haven’t gone through that I would recommend you to quickly look at that first and then come back here.
Today we will create a Servlet which simply prints “Hello World!”. Later we will start adding parameters to our request and will try to print that. We will use other features of Servlet like session and context in our subsequent tutorials.
Sometimes starting with your Eclipse Web Tool Platform(WTP) you might fumble while configuring Apache Tomcat server to your Project. Today we will quickly check how its done. I hope you have extracted the Apache tomcat binary in your local system and your Eclipse editor is running. Now having that in mind you can follow these few steps:
Spring JdbcTemplate is a powerful mechanism to connect to the database and execute SQL queries. It internally uses JDBC api, but eliminates a lot of problems of JDBC API.
Problems with JDBC API
We all are aware of the JDBC(Java Database Connection) to connect the Java application to database for various DML and DDL operation and storing the data in database.
- For doing a CRUD(Create Retrieve Update Delete) operation in simple JDBC we have to write a lot of code as well as have to think and handle each and every exception scenario.
- We need to perform exception handling code on the database logic.
- We need to handle transaction.
- Repetition of all these codes from one to another database logic is a time consuming task.
Below is the basic code for a select query via JDBC.