A typical multi-layered JAVA application uses multiple frameworks which have evolved over time. In this post I will attempt to give a quick snapshot of frameworks that a typical JAVA based web application might be using.
What is web application?
As per wiki, a web application or web app is a client–server software application in which the client (or user interface) runs in a web browser. Again the web application can be dynamic and static. Each web page in a static app is a seperate html document. So, if you want to edit any section of the page the only way is to login to the page and edit the HTML whereas a dynamic web app has greater degree of functionality. Each web page in a dynamic web app is generated based on the information store in the DB. In today’s dynamic world where the things are changing in every seconds, it’s almost impossible to maintain a static web app. There are many technologies evolved such as PHP, Java/J2EE, ASP which has made a dynamic web app creation simple. Here we will be discussing about the different options available in Java to create a dynamic web app, starting from the core J2EE to advanced frameworks available in Java.
Basically there are two programming methods – procedural programming and object -oriented programming. Before evolution of object – oriented programming, C , Qbasic were some powerful procedural programming. Java is an object orientd programming which was released in 1995 as a core component of Sun Microsystems’ Java platform. It is intended to let application developers “write once, run anywhere” (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture.
Why Java For Web Development
- It relatively easy to find maintenance programmers if necessary.
- The Java / J2EE archetecture is robust and reasonably elegant. It makes it possible to archetect well built applications.
- The free tools available for it are enterprise ready. For example, Apache / Tomcat / JBoss are a solid foundation to build a web-app from.
- There is a good availability of third-party (and open-source) libraries and Eclipse plug-ins for most of the additional functionality that might be needed but does not come in the core libraries.
- There is also great support tools from commercial vendors: Oracle; IBM / Rational; etc.
- Updated versions with newer language constructs are constantly being developed.
- More Secure and provide fast server side processing.
What is J2EE?
J2EE stands for Java 2 Platform Enterprise Edition. It provides a platform-independent environment for developing, building and deploying dynamic Web-based enterprise applications online. The J2EE platform consists of a set of services, APIs, and protocols that provide the functionality for developing multitiered, Web-based applications. Talking about the architecture, J2EE has a MVC(Model View and Controller) architecture. Here model are the java beans that represents the columns of the DB. Controller(Servlet) provides logic to your app. And view includes JSP or html pages that is presented to the browser client.
But the issue with using core Servlet is that the writing complex business logic makes the application difficult to understand. You CAN use servlets to write a web application, but you’ll have to handle all of the details manually. You’ll get very little help with typical web stuff like validation, REST, request/response body for JSON, form binding, etc. You will end up writing lot of utility code to support your web application. Hence you write more and get less. Using raw servlets can be a good learning experience though.
What is JDBC?
JDBC id the API to communicate with the underlying DB. But JDBC is not easy if it is used in large projectswhere in there is lot of INSERTIONS/UPDATIONS. Because, lots of transaction control needs to be programmed by the developer and I would choose ejb or other ORM mechanism over JDBC.But JDBC is more beneficial when the application has lots of SELECTS and the end users are not really bothered about how real time the data is?
What is Spring?
Here comes the Spring, which is essentially a higher level abstraction built on top of Java Servlets centered around the Model View Controller design pattern. It has tons of utility classes and features. The most important is dependency injection. In a real time application, the main challenge is to manage the beans and dependencies and Spring does that for you with very minimal configurations. Many developers also prefer Spring because of its modularity. Spring provides excellent integration with any of its modules in simple steps. It helps a lot in reducing Boiler-plate code and provides declarative programming through aspects and common conventions.
Apart from this Spring has its own jdbc template to handle the complex and boiler plate code to make DB transactions. It has also its own ORM tool. But developer mostly prefer Hibernte over Spring JPA.
What is Hibernate?
Hibernate is an ORM(Object Relational Mapping) tool.There are many ORM tools available like OpenJPA, eclipselink and many others. All of them has their own limitations. The most preferred is Hibernate. It automatically maps your DB table and columns to the Java beans and its attributes. For a object oriented programmer, It presents relational database as an object oriented fashion. Hence very useful for a developer to focus on the business logics rahther than mappping between DB and web app architecture. Also its not straightforward to maintain sessions and transactions to DB from java web app using JDBC but Hibernate handles everything for you.
What is JMS?
Java Message Service (JMS) is an application program interface (API) that supports the formal communication known as messaging between computers in a network. The messages involved exchange crucial data between computers – rather than between users – and contain information such as event notification and service requests asynchronously. spring provides excellent integration with JMS. There are many brokers available that JMS depends on like ActiveMQ, RabbbitMQ.
What are WebSocets?
WebSockets is a protocol that allows the server to send things to the browser without the browser having to request it. WebSockets are a bi-directional, full-duplex, persistent connection between a web browser and a server. Once a WebSocket connection is established the connection stays open until the client or server decides to close this connection.
The best fit for WebSocket is in web applications where the client and server need to exchange events at high frequency and with low latency. Prime candidates include, but are not limited to, applications in finance, games, collaboration, and other real time apps. Spring 4 supports WebSocket integration over STOMP client. And very easy to integrate websocket with Spring.
What’s on the Client Side?
This is all abou the technologies. We will be discussing about the different tools used in Java/J2EE app in next post.
You can visit my website (http://www.devglan.com) for detailed insights and solutions to challenges faced in Java based applications.