The hello.zac application you built in the previous lesson has the virtue of simplicity, but it also has a significant drawback - it uses the servlet to mix page design (all the HTML tags) with application logic (the dynamic behaviors.) For such a small and simple application, this may not be a problem, but for larger and more complex applications, it is better practice to separate these functions. The reasoning is simple. If your company gets a new logo, the designer should be able to change it without delving into the Java programming logic. For that matter, ideally the designer could change it in one file, without having to repeat the process for every page on the site.
JavaServer pages provide this kind of functionality. When you have pages with dynamic content, you can include tags in your JSP file that ask the servlet for that content. The servlet capsule holds the actual behaviors and actors that generate or process the dynamic content for the page.
There are many standard JSP tags that provide useful functionality for a web application. JSP is also an extensible standard. That is, you can define new methods in your servlets and create a reusable tag library to help create and maintain your site.
For more information on JavaServer Page technology, see:
In this part of the tutorial, you will build a servlet capsule that takes a series of numbers from a user, asks the user to select some mathematical operations to perform on each number in the series, and then displays the results in a table. You will create the capsule as part of a project, and enable it to interact with HTML, JSP and image files. You will use some types of actors and behaviors that you have not yet encountered in AppComposer. Once you have built the capsule, you will use it to explore AppComposer's debugging functionality.
To build this capsule, this tutorial shows you how to accomplish the following new things:
Although it is not required to do the exercises in this tutorial, familiarity with HTML and basic programming (in any language) will make it easier to understand many of the new concepts presented here.