Java Server Pages - putting it all together
Archive - Originally posted on "The Horse's Mouth" - 2010-02-26 17:07:43 - Graham EllisI've been teaching Java Server Programming to newcomers this week ... and here are three example that I wrote today, pulling much of the work together.
1. An example of a JSP (Java Server Page) that opens and reads an entire file into an ArrayList of (in this case) String objects, then performs an analysis of that ArrayList and provides the result back to the user. [here]
2. A simple JSP that reads data from a form, then calls up business logic that's encapsulated in a class elsewhere in the web application. The code for the JSP is [here] and the class it calls up is [here].
3. Java Server Pages can use tag libraries rather than Java source code to call up constructors and methods (provided that they conform to the Java Bean standard). That means that the team members who are writing the look and feel pages (the graphic artists who are defining the view) don't neet to be Java programmers. The third JSP example uses basic tag libraries (and I have included the equivalent Java code as comments to help you read what it is doing). The source is [here]. The Java bean class that it calls may be found [here].