Over a million developers have joined DZone.

Interview: Troy Giunipero, Author of NetBeans E-commerce Tutorial

· Java Zone

Bitbucket is for the code that takes us to Mars, decodes the human genome, or drives your next car. What will your code do? Get started with Bitbucket today, it's free.

Troy Giunipero (pictured, right) is a student at the University of Edinburgh studying toward an MSc in Computer Science. Formerly, he was one of the NetBeans Docs writers based in Prague, Czech Republic, where he spent most of his time writing Java web tutorials.

In this interview, Troy introduces you to The NetBeans E-commerce Tutorial. This is a very detailed tutorial describing just about everything you need to know when creating an e-commerce web application in Java. It has received a lot of very positive feedback. Let's find out about the background of this tutorial and what Troy learnt in writing it.

Hi Troy! During your time on the NetBeans team, you wrote a very large tutorial describing how to create an e-commerce site.  How and why did you start writing it?

Well, there’s a short answer and a long answer to this.  The short answer is that I was lucky to take part in Sun’s SEED (Sun Engineering Enrichment and Development) program.  I wanted to focus on technical aspects, so I based my curriculum on developing an e-commerce application using Java technologies.  I documented my efforts and applied them toward deliverables for the IDE’s 6.8 and 6.9 releases, resulting in the 13-part NetBeans E-commerce Tutorial.

The long answer is that I had previously been tasked with creating an e-commerce application for my degree project (I was studying toward a BSc in IT and Computing), and ran into loads of trouble trying to integrate the various technologies into a cohesive, functioning application.  I was coming from a non-technical background and found there was a steep learning curve involved in web development.  My work was fraught with problems which I can now attribute to poor time-management, and a lack of good, practical, hands-on learning resources.  So in a way, working on the AffableBean project (this is the project used in the NetBeans E-commerce Tutorial) was a way for me to go back and attempt to do the whole thing right.  With the tutorial, I had two goals in mind: one, I wanted to consolidate my understanding of everything by writing about it, and two, I wanted to help others avoid the problems and pitfalls that I’d earlier ran into by designing a piece of documentation that puts everything together.

Can you run us through the basic parts and what they provide?

Certainly.  First I want to point out that there’s a live demo application (http://dot.netbeans.org:8080/AffableBean/) which I managed to get up and running with help from Honza Pirek from the NetBeans Web Team (thanks Honza!):

The application is modeled on the well-known MVC architecture:

The tutorial refers to the above diagram at various points, and covers a bunch of different concepts and technologies along the way, including:

  • Project design and planning (unit 2)
  • Designing a data model (using MySQL WorkBench) (unit 4)
  • Forward-engineering the data model into a database schema (unit 4)
  • Servlet, JSP/EL and JSTL technologies (units 3, 5, 6)
  • EJB 3 and JPA 2 technologies (unit 7), and transactional support (unit 9)
  • Session management (i.e., for the shopping cart mechanism) (unit 8)
  • Form validation and data conversion (unit 9)
  • Security (i.e., using form-based authentication and encrypted communication) (unit 11)
  • Monitoring the application with the IDE’s Profiler (unit 12)
  • Tips for deployment to a production server (units 12, 13)

Also, the tutorial aims to provide ample background information on the whole “Java specifications” concept, with an introduction to the Java Community Process, how final releases include reference implementations, and how these relate to the tutorial application using the IDE’s bundled GlassFish server (units 1, 7).

Finally, the tutorial is as much about the above concepts and technologies as it is about learning to make best use of the IDE.  I really tried to squeeze as much IDE-centric information in there as possible.  So for example you’ll find:

  • An introduction to the IDE’s main windows and their functions (unit 3)
  • A section dedicated to editor tips and tricks (unit 5), and abundant usage of keyboard shortcuts in steps throughout the tutorial
  • Special “tip boxes” that discuss IDE functionality that is sometimes difficult to fit into conventional documentation.  For example, there are tips on using the IDE’s Template Manager (unit 5), GUI support for database tables (unit 6), Javadoc support (unit 8), and support for code templates (unit 9).

Did you learn any new things yourself while writing it?

Yes!  Three things immediately come to mind:

  • EJB 3 technology.  Initially this was a big hurdle for me.  Using EJB 3 effectively seems to be something of an art form.  If you know what you’re doing and understand exactly how to use the EntityManager to handle persistence operations on a database, EJB lets you do some amazingly smart things with just a few lines of code.  But there seems to be a lack of good free documentation online—especially since EJB 3 is a significant departure from EJB 2.  Therefore, almost all of the tutorial’s information on EJB comes from the very excellent book, EJB in Action by Debu Panda and Reza Rahman.

  • Interpreting the NetBeans Profiler.  The final hands-on unit, Testing an Profiling, was the most difficult for me to write, primarily because I just wasn’t familiar with the Profiler at all.  I spent an unhealthy amount of time just watching the Telemetry graph run against my JMeter test plan, which is only slightly more stimulating than watching water come to boil.  That being said, I feel that by just examining the graphs and other windows over time, critical logical associations start to jump out at you after a while.  Likewise with JMeter.  Hopefully unit 12 was able to capture and relay some of these.

  • How to search online for decent articles and learning materials.  The old Sun Technical Articles site was a great resource.  Many of the links in the See Also sections at the bottom of tutorial units were found by adding site:java.sun.com/developer/technicalArticles/ to a Google search.  Also the official forums (found at forums.sun.com) became a good place for questions I couldn’t find ready answers to.  I had both the Java EE 5 and 6 Tutorials bookmarked.  And Marty Hall’s Core Servlets and JavaServer Pages became an invaluable resource for the first half of the tutorial.

What are your personal favorite features of the technologies discussed in the tutorial?

I particularly liked learning about session management—using the HttpSession object to carry user-specific data between requests, and working with JSP’s corresponding implicit objects in the front-end pages.  Session management is a defining aspect for e-commerce applications, as they need to provide some sort of shopping cart mechanism...

...and so the Managing Sessions unit (unit 8) was a key chapter in the tutorial.  It’s extremely useful to be able to suspend the debugger on a portion of code that includes session-scoped variables, then hover the mouse over a given variable in the editor to determine its current value.  I used the debugger continuously during this phase, and so I went so far as to incorporate use of the debugger throughout the Managing Sessions unit.

What kind of background does someone starting the tutorial need to have?

Someone can come to the tutorial with little or absolutely no experience using NetBeans.  I’ve tried to be particularly careful in providing clear and easy-to-follow instructions in this respect.  But one would be best off having some background or knowledge in basic web technologies, and at least some exposure to relational databases.  With this foundation, I think that the topics covered in the second half of the tutorial, like applying entity classes and session beans, language support and security, won’t seem too daunting.

I’ve noticed that the vast majority of feedback that comes in relates to the first half of the tutorial, and I sometimes get the impression that people feel they need to follow the tutorial units consecutively.  Not so.  The units are 90% modular.  In other words, if somebody just wants to run through the security unit (unit 11), they can do so by downloading the associated project snapshot, follow the setup instructions, and then just follow along without needing to even look at other parts of the tutorial.

What will they be able to do at the end of it?

Naturally, anybody who completes individual tutorial units will be able to apply the concepts and technologies to their own work.  But anyone who completes the tutorial in its entirety will gain an insight into the development process as a whole, and I think will also get a certain confidence that comes with knowing how “all the pieces fit together”—from gathering customer requirements all the way to deployment of the completed app to a production server.  They’ll also have gained a solid familiarity with the NetBeans IDE, and be in a good position to explore popular Java web frameworks that work on top of servlet technology or impose an MVC architecture on their own, such as JSF, Spring, Struts, or Wicket.

Do you see any problems in the technologies discussed and what would be your suggestions for enhancements?

Well there’s one thing that comes to mind.  When I started working on this project, I was studying the Duke’s BookStore example from the Java EE 5 Tutorial.  A wonderful example that demonstrates how to progressively implement the same application using various technologies and combinations thereof.  So for example you start out with an all-servlet implementation, then move on to a JSP/servlet version.  Then there’s a JSTL implementation and ultimately, a version using JavaServer Faces.  It’s great learning material, but also terrifically outdated.  Right around this time, Sun was gearing up for the big Java EE 6 release (Dec. 2009), and I was also trying to learn about the new upcoming technologies, namely CDI, JSF 2, and EJB 3, for my regular NetBeans documentation work.  I was getting the definite sense that JSP and JSTL were slowly being pushed aside—in the case of JavaServer Faces, Facelets templating was the new page authoring technology.  So really, the E-commerce Tutorial application has become a sort of EE 5/EE 6 hybrid by combining JSP/JSTL with EJB 3 and JPA 2.

Now the problem I see from the perspective of a student trying to learn this stuff from scratch, is that the leap from basic servlet technology to a full-blown JSF/EJB/JPA solution is tremendous, and cannot readily be taught through a single tutorial.  Naturally, others may disagree with me here.  I’m not sure if there’s a solution other than to compensate by producing a lot of quality learning material that covers lots of different use-cases.  I’d suggest that the E-commerce Tutorial puts one in a very advantageous position to begin learning about Java-based frameworks, such as GWT, Spring, and JSF, which is a natural course of action for people looking to get a job with this knowledge.

Planning any more parts to the tutorial or a new one?

No more parts.  The E-commerce Tutorial is done.  Upon committing the final installments and changes last November, I rejoiced.  However, I’m still actively responding to feedback [the ‘Send Us Your Feedback’ links at the bottom of tutorials] and plan to maintain it indefinitely, so if anyone spots any typos, has questions or comments, recommendations for improvement, etc., please write in! :-)

Bitbucket is the Git solution for professional teams who code with a purpose, not just as a hobby. Get started today, it's free.


Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}