Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Java EE 8 Development with Eclipse
Java EE 8 Development with Eclipse

Java EE 8 Development with Eclipse: Develop, test, and troubleshoot Java Enterprise applications rapidly with Eclipse , Third Edition

eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Java EE 8 Development with Eclipse

Creating a Simple JEE Web Application

The previous chapter gave you a brief introduction to JEE and Eclipse. We also learned how to install the Eclipse JEE package and also how to install and configure Tomcat. Tomcat is a servlet container and it is easy to use and configure. Therefore, many developers use it to run JEE web applications on local machines.

In this chapter, we will cover the following topics:

  • Configuring Tomcat in Eclipse and deploying web applications from within Eclipse
  • Using different technologies to create web applications in JEE, for example, JSP, JSTL, JSF, and servlets
  • Using the Maven dependency management tool

Configuring Tomcat in Eclipse

We will perform the following steps to configure Tomcat in Eclipse:

  1. In the Java EE perspective of Eclipse, you will find the Servers tab at the bottom. Since no server is added yet, you will see a link in the tab as shown in the following screenshot—No servers are available. Click this link to create a new server...
Figure 2.1: The Servers tab in Eclipse JEE
  1. Click the link in the Servers tab to add a new server.
  2. Expand the Apache group and select the Tomcat version that you have already installed. If Eclipse and the Tomcat server are on the same machine, then leave Server's host name as localhost. Otherwise, enter hostname or IP address of the Tomcat server. Click Next:
Figure 2.2: Selecting a server in the New Server wizard
  1. Click the Browse... button and select the folder where Tomcat is installed.
  1. Click...

JavaServer Pages

We will start with a project to create a simple JSP. We will create a login JSP that submits data to itself and validates the user.

Creating a dynamic web project

We will perform the following steps to create a dynamic web project:

  1. Select the File | New | Other menu. This opens the selection wizard. At the top of the wizard, you will find a textbox with a cross icon on the extreme right side.
  2. Type web in the textbox. This is the filter box. Many wizards and views in Eclipse have such a filter textbox, which makes finding items very easy.
Figure 2.7: New selection wizard
  1. Select Dynamic Web Project and click Next to open the Dynamic Web Project wizard. Enter project name, for example, LoginSampleWebApp...

Java Servlet

We will now see how to implement a login application using Java Servlet. Create a new Dynamic Web Application in Eclipse as described in the previous section. We will call this LoginServletApp:

  1. Right-click on the src folder under Java Resources for the project in Project Explorer. Select the New | Servlet menu option.
  2. In the Create Servlet wizard, enter package name as packt.book.jee_eclipse.book.servlet and class name as LoginServlet. Then, click Finish.
Figure 2.22: Create Servlet wizard
  1. The servlet wizard creates the class for you. Notice the @WebServlet("/LoginServlet") annotation just above the class declaration. Before JEE 5, you had to declare servlets in web.xml in the WEB-INF folder. You can still do that, but you can skip this declaration if you use proper annotations. Using WebServlet, we are telling the servlet container that...

Creating WAR

Thus far, we have been running our web application from Eclipse, which does all the work of deploying the application to the Tomcat server. This works fine during development, but when you want to deploy it to test or production servers, you need to create a web application archive (WAR). We will see how to create a WAR from Eclipse. However, first we will un-deploy the existing applications from Tomcat.

  1. Go to the Servers view, select the application, and right-click and select the Remove option:
Figure 2.23 Un-deploy a web application from the server
  1. Then, right-click on the project in Project Explorer and select Export | WAR file. Select the destination for the WAR file:
Figure 2.24 Export WAR

To deploy the WAR file to Tomcat, copy it to the <tomcat_home>/webapps folder. Then start the server if it is not already running. If Tomcat is...

JavaServer Faces


When working with JSP, we saw that it is not a good idea to mix scriptlets with the HTML markup. We solved this problem by using JavaBean. JavaServer Faces takes this design further. In addition to supporting JavaBeans, JSF provides built-in tags for HTML user controls, which are context aware, can perform validation, and can preserve the state between requests. We will now create the login application using JSF:

  1. Create a dynamic web application in Eclipse; let's name it LoginJSFApp. In the last page of the wizard, make sure that you check the Generate web.xml deployment descriptor box.
  2. Download JSF libraries from https://maven.java.net/content/repositories/releases/org/glassfish/javax.faces/2.2.9/javax.faces-2.2.9.jar and copy them to the WEB-INF/lib folder in your project.
  3. JSF follows the MVC pattern. In the MVC pattern, the code to generate user interface (view) is separate from the container of the data (model). The controller acts as the interface between the view and...

Using Maven for project management


In the projects that we have created thus far in this chapter, we have managed many project management tasks, such as downloading libraries on which our project depends, adding them to the appropriate folder so that the web application can find it, and exporting the project to create the WAR file for deployment. These are just some of the project management tasks that we have performed so far, but there are many more, which we will see in the subsequent chapters. It helps to have a tool do many of the project management tasks for us so that we can focus on application development. There are some well-known build management tools available for Java, for example, Apache Ant (http://ant.apache.org/) and Maven (http://maven.apache.org/).

In this section, we will see how to use Maven as a project management tool. By following the convention for creating the project structure and allowing projects to define the hierarchy, Maven makes project management easier...

Summary


In this chapter, we learned how to configure Tomcat in Eclipse. We learned how the same web page can be implemented using three different technologies, namely JSP, Servlet, and JSF. All of them can be used for developing any dynamic web application. However, JSP and JSF are better suited for more UI-intensive pages, and servlets are better suited for controllers and as endpoints for web services and WebSockets. JSF enforces the MVC design and provides many additional services compared to JSP.

We also learned how to use Maven for many project management tasks.

In the next chapter, we will learn how to configure and use source control management systems, particularly SVN and Git.

Left arrow icon Right arrow icon

Key benefits

  • •Explore the complete workflow of developing enterprise Java applications
  • •Develop microservices with Docker Container and deploy it in cloud
  • •Simplify Java EE application development

Description

Java EE is one of the most popular tools for enterprise application design and development. With recent changes to Java EE 8 specifications, Java EE application development has become a lot simpler with the new specifications, some of which compete with the existing specifications. This guide provides a complete overview of developing highly performant, robust and secure enterprise applications with Java EE with Eclipse. The book begins by exploring different Java EE technologies and how to use them (JSP, JSF, JPA, JDBC, EJB, and more), along with suitable technologies for different scenarios. You will learn how to set up the development environment for Java EE applications and understand Java EE specifications in detail, with an emphasis on examples. The book takes you through deployment of an application in Tomcat, GlassFish Servers, and also in the cloud. It goes beyond the basics and covers topics like debugging, testing, deployment, and securing your Java EE applications. You'll also get to know techniques to develop cloud-ready microservices in Java EE.

Who is this book for?

If you are a Java developer with little or no experience in Java EE application development, or if you have experience in Java EE technology but are looking for tips to simplify and accelerate your development process, then this book is for you.

What you will learn

  • •Set up Eclipse, Tomcat, and Glassfish servers for Java EE application development
  • •Use JSP, Servlet, JSF, and EJBs to create a user interface and write business logic
  • •Create Java EE database applications using JDBC and JPA
  • •Handle asynchronous messages using MDBs for better scalability
  • •Deploy and debug Java EE applications and create SOAP and REST web services
  • •Write unit tests and calculate code coverage
  • •Use Eclipse MAT (Memory Analysis Tool) to debug memory issues
  • •Create and deploy microservices

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 29, 2018
Length: 596 pages
Edition : 3rd
Language : English
ISBN-13 : 9781788833776
Vendor :
Oracle
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jun 29, 2018
Length: 596 pages
Edition : 3rd
Language : English
ISBN-13 : 9781788833776
Vendor :
Oracle
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 103.97
Building RESTful Web Services with Java EE 8
€24.99
Java EE 8 Development with Eclipse
€41.99
Java EE 8 Design Patterns and Best Practices
€36.99
Total 103.97 Stars icon

Table of Contents

15 Chapters
Introducing JEE and Eclipse Chevron down icon Chevron up icon
Creating a Simple JEE Web Application Chevron down icon Chevron up icon
Source Control Management in Eclipse Chevron down icon Chevron up icon
Creating JEE Database Applications Chevron down icon Chevron up icon
Unit Testing Chevron down icon Chevron up icon
Debugging the JEE Application Chevron down icon Chevron up icon
Creating JEE Applications with EJB Chevron down icon Chevron up icon
Creating Web Applications with Spring MVC Chevron down icon Chevron up icon
Creating Web Services Chevron down icon Chevron up icon
Asynchronous Programming with JMS Chevron down icon Chevron up icon
Java CPU Profiling and Memory Tracking Chevron down icon Chevron up icon
Microservices Chevron down icon Chevron up icon
Deploying JEE Applications in the Cloud Chevron down icon Chevron up icon
Securing JEE Applications Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
(1 Ratings)
5 star 0%
4 star 0%
3 star 100%
2 star 0%
1 star 0%
Original Elvis Nov 28, 2018
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
The prerequisites for Java EE 8 Development with Eclipse are basic knowledge of the Java language and object-oriented programming similar to what you'd have after working through Headfirst Java and Headfirst Object-Oriented Design. Rudimentary knowledge of your operating system and how environment variables are set is also necessary. Unix/GNU Linux based readers should understand Unix file permissions and how to create and add users to groups to solve any read/write problems they encounter. Introductory knowledge of HTML forms and GET/POST submissions to a web server is helpful.Java EE 8 Development with Eclipse was written for developers new to Java/Jarkarta Enterprise Edition, formerly known as J2EE. It provides specific examples, and walks the reader through them step-by-step. Exposition is kept to a minimum, but the author provides enough information for the reader to understand what they're working with and why they are inputting code; furthermore, the author points out when the examples deviate from actual production design patterns. The third edition of the book adds new chapters for microservices using Docker, deploying JEE applications in Amazon Web Services (AWS), and securing JEE Applications. Readers that complete the book will have the basics that they can use as a foundation for further supplemental learning. Many of the JEE technologies discussed have tutorials available online for free. Readers who prefer books should consider Java EE 7 The Big Picture (ISBN 978-0-07-183734-7) by Dr. Danny Coward for the historical architectural perspective of JEE and Java EE 8 Application Development (ISBN 978-1-78829-367-9) by David R. Heffelfinger for better coverage of JEE 8 written from a practicing programmer perspective (David Heffelfinger gets PUT vs. POST wrong in Chapter 10 by using PUT for new operations and POST for updates. He also uses tables for user input like logins instead of CSS.)Unfortunately, much of the text for Java EE 8 Development with Eclipse was carried over from second edition, which was written for Java 7, Apache Tomcat 7, and MySQL version 5. Java 8 deprecated managed beans in favor of context-dependency injection (CDI) beans; yet the author continues to use managed beans in the examples. The recommendation to use JDK 1.7 on page 3 in the Preface is a dead give-away to the book's older roots despite the cover claiming Java 8 support.Readers modernizing the sample applications to Java 8 and beyond with the latest jar files will encounter headaches that are just as instructional as the book itself. Apache Tomcat is a basic servlet and Java Server Page (JSP) web server. It requires additional Maven java jar files to support CDI beans and various java front-end technologies like Java Standard Template Language (JSTL) and Java Server Faces (JSF). The examples in the book are understandably missing some of the configuration steps when the reader updates to MySQL version 8, CDI beans, the latest jar files, and a 3rd party bean manager like JBOSS Weld. A lot of these configuration headaches could have been avoided if the author stuck to using Glassfish server throughout the book, or if he adopted Apache TomEE, which is Apache Tomcat updated for all the extra JEE components covered in the book. Readers substituting the book's Apache Tomcat server with something more modern should make liberal use of the <scope>provided</scope> attribute for their Maven dependencies.I was a bit disappointed with the database examples in Chapter 4. The author cleverly adds fields that accept null values to the examples - most notably the last name field, so celebrities like Sting or Cher could be instructors or students - but then leaves the update and delete steps for CRUD operations as an exercise for the reader. Since objects and text fields resolve to NULL by default, it makes a big difference when performing updates on records that accept null values verses those set to NOT NULL in the database. This was a great instructional opportunity that was completely missed in the book; but I give the author credit for including null fields, because most authors follow the happy path in their database designs.Eclipse in 2018 still has some annoying bugs and warnings that the author could have documented for new users. For example, many new projects will report themselves as Java SE 1.5 even though the JAVA_HOME environment variable is set. This causes Eclipse to display warnings about mismatched Dynamic Web and Java versions for Project Facets. The solution is to right-click the project, select Preferences and update the Java Build variable to 1.8 (the version used for the book), then go to Project Facets and change Dynamic Web to 4.0 and Java Version to 1.8. Sometimes the Properties UI dialog throws an exception, and when that happens, the user must go to the settings folder for their project in the Eclipse Workspace folder, open org.eclipse.wst.common.project.facet.core.xml, change the jst.web setting version from 2.3 to 4.0, and save the file. The java version can also be updated in the xml file if the user wants to bypass the Properties dialog UI entirely. Showing users how to eliminate some of Eclipse's bogus warnings while working on the exercises would definitely move the book towards a 5 star rating.Readers new to web development should also realize that many of the examples in the book render elements in tables, partly as a result of what the stock Java Server Faces (JSF) API renders as html output. It was the preferred approach when JSF was initially created in the aughts, but in 2018 outputting html for items that don't belong in tables - like a simple web login form - causes headaches for front-end web designers modifying the site with Cascading Style Sheets, mobile users, and visually impaired users using reader software. Keep this in mind as you transition from book exercies to actual production code.In conclusion, if you're new to JEE and willing to put in some effort correcting and updating the author's examples, this book is a good starting point because it offers step-by-step instructions. Working through the book's exercises meets its stated objectives of providing an overview of JEE technologies, hands-on experience with the Eclipse IDE, and an introduction to the Maven build system. If you don't have any interest in the Docker or AWS coverage, you can save yourself some money by buying the second edition of the book. I recommend pairing this book with David Heffelfingers Java EE 8 Application Development as a reference when replacing managed beans with CDI beans. 3/5 stars. The material is 4 star worthy, but I'm deducting a star for the coding errors, outdated APIs, minimal samples (no data validation or update/delete operations), and the use of an older version of MySQL.Check the comments section below where I correct most of the problems with the book. I submitted these notes to the publisher Packt as errata for their website, but they've been slow to post it. Thanks to Amazon comments, you can find the errata here.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.