Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explain: How does Java work as a web application?

Ok, I know this is a vague question, and I expect a vague/basic answer.

I am well versed with PHP driven MVC frameworks and how the process of serving pages works. I'm very interested in learning Java, and I figure the only way to learn it is to do it. However, after reading page after page after page, it gets more confusing as I read.

I'm running into GWT (front end), Hibernate (ORM connection?), Spring Architecture, Spring Roo (what is this?), JBoss (servelet), JPA (ORM), POJO (a style of using regular java objects with orm?), Maven?

My basic question is how do all of these fit together? I like the idea of using a framework, because it's worked well in the past with PHP. How do I use this functionality with java? Suppose I wanted to build a web application with a relational data store. How does java authenticate, initate a session, and serve pages with dynamic content? What is the process?

When responding, please don't say "stick with what you know," (as I've seen on other pages) because I'm very interested about java and I'm trying to learn.

like image 599
Logan Klenner Avatar asked Mar 13 '12 15:03

Logan Klenner


People also ask

How does a web application work?

Web apps retrieve and store information by using server-side scripts (in scripting languages such as PHP and ASP), while client-side scripts (in JavaScript and HTML5) present the relevant information on the user interface. This information might take any number of forms.

Can Java create web application?

Java provides support for web application through Servlets and JSPs. We can create a website with static HTML pages but when we want information to be dynamic, we need web application.

Which edition of Java is used for web application?

J2EE(Java Platform, Enterprise Edition) J2EE uses HTML, CSS, JavaScript etc., so as to create web pages and web services. It's also one of the most widely accepted web development standard. There are also many languages like .


1 Answers

I totally hear you - too many acronymns have propped up as Java EE has evolved.

I will try to put an explanation Java is the language Java EE (Java Enterprise Edition) is the general term used to encapsulate all Java technologies that help create an enterprise/web application with Java

So a typical web application with Java looks like follows:

Front End

  • Use JSP or JSF for server side processing and rendering (JSP and JSF offer ability to define your UI using HTML and server side tags that bind easily with your Java Beans) However they do tend to mix UI with backend if not implemented correctly
  • you can also use plain HTML and any client side toolkits for rendering (such as jquery, dojo, extjs or flex) and fetch your data from the Java EE server.
  • you can even mix the two (use a client side framework in a JSP to achieve best of both) or use a toolkit like GWT that offers client side richness with javascript with Java APIs and ease of accessing your java beans

Middle tier

  • Java Servlets offer the base for all server side processing with Java EE (Servlets offer session persistence, HTTP request processing, response processing) and typically offload the business processing to a model bean - which could be a POJO or spring bean. Servlets are Java programs you write and are executed in what is called a Java EE container. Popular containers are tomcat, IBM websphere, BEA Weblogic

To help implement a good MVC architecture, there are several frameworks and tools provided on top of Servlets:

  • Struts2 and Spring MVC are examples of such frameworks
  • To make it easy to implement web services, Restlet/Jersey help with REST based web services, JAX-WS/APache Axis help with SOAP based web services

Integration with backend database/persistent store

  • You could use JDBC in your POJO or other model bean to access the DB using Java.
  • Or alternately use one of the frameworks such as Hibernate to make it easy to interface with the DB backend

Sun's petstore application is a good place to start to learn how the pieces fit together

http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-eedocs-419425.html#7522-petstore-1.1.2-oth-JPR

Build and Deployment

  • Ant and Maven are tools used to build your app and manage dependencies
  • the application gets packaged as a WAR or EAR file and can be dropped into any Java EE container to deploy it. Once it is deployed, it can be accessed using a URL
  • Tools like Eclipse, Netbeans, Oracle JDeveloper offer integrated IDEs to help with local deployment and testing

The good part with Java EE is that you can pick and choose the components you want to use to build your webapp.

like image 159
Vijay Agrawal Avatar answered Sep 21 '22 05:09

Vijay Agrawal