Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Java Beans, tag libraries and JSPs - what and why.

Java Programming - training course! - just completed. We went a long way from the first steps in Java on Monday through to Servlets and Java Server Pages (JSPs) on Friday - and yet in many ways, our course goes full circle. For, through Java Server Pages, you can keep the look and feel of a web site separated from the business logic, and produce meaningful pages that contain - in the HTML - remarkablly little code if any. This excellent approach (sometimes known as MVC / Model, View, Controller) allows you to have your web page appearence looked after by those members of your team who are good graphic artists, and to have your actions looked after by other members of the team - the good analyst / programmers. You have a good interface between the two, you can change the way the thing works without the appearance, and the appearance without changing how it works. And you can have the page updated easily without having to employ a multi-skilled person - a graphic artist who's a programmer too (and who is, perhaps, only mediocre at one of those skills).

To show you what I mean ... from Friday, [here] is a link to a JSP page. You'll find that it has a grand total of two complete Java statements, and two other references to Java variables. The rest is all HTML.

A further example - [here] adds in a bit more code - but the complexity of doing the MySQL database lookup and presenting the results back has all been put into the net.wellho.Book class which is the responsibility of the programmer.

We can get rid of even that small amount of Java source code by providing the graphic artist with a tag library - in the third example in this series, [here], all the Java has gone to be replaced by tags which are very similar to HTML tags, but are replaced by results on the web server before being sent out to the site visitor's browser / client.

As well as the standard tag library, there are othe libraries available such as Spring and Struts. Those are beyond the scope of a course that takes you from "what is Java" in just a week - but at the end of the week it's good to be given the roadmap ahead and know where you may be headed.

• Above here - the graphic artist
• Below here - the programmer


The examples above apply a look and feel to a database lookup that needs to be codes. And the API (Application programmer interface) that the tag library uses is a Java Bean. What that means is that the program logic is going to be in a Java class, which must have a constructor that takes no parameters. Information (properties) are put in using methods with names like setIsbn where the word "set" is used to identify this as a method which supplies data to th eclass, and getAuthor where the word "get" identifies the method as one to extract data.

The net.wellho.Book class is such a bean - and that means that the tag libraries (which require that such a convention has been followed, thus turning it into a rule as far as they are concerned) can make use of it. You can find the source of the class [here] and you'll note that - like all good classes - it has its own main test harness so that you can check it out independently of the JSP / tag library / web level.
(written 2010-11-13)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
J907 - JSP - JavaServer Pages
  [79] Last day of Java - (2004-10-08)
  [1050] The HTML++ Metalanguage - (2007-01-22)
  [1550] Java (JSP and Servlet examples) live on our server - (2008-02-23)
  [2147] A very easy JSP (Java Server Page) - (2009-05-01)
  [2151] What is a JSP tag library? - (2009-05-01)
  [2183] Servlet life cycle, and Java Servlet variable scope - (2009-05-16)
  [2525] Using JSPs, Tag Libraries, Java Beans, Tomcat in one short example - (2009-12-04)
  [3997] Servlet v JSP (Java Server Page). What is the difference? - (2013-02-06)

J812 - Java Beans
  [1074] Java beans and classes, .war and .jar files - (2007-02-10)
  [2155] No subject or title? - (2009-05-03)

J811 - Java - JDBC - Relational Database Access
  [515] MySQL - an FAQ - (2005-12-03)
  [2154] Bean Classes in Java and Java Database Connections - (2009-05-02)
  [2861] MySQL and Java - connectivity past, present, and future thoughts - (2010-07-09)

A508 - Web Application Deployment - Jakarta and Struts

Back to
After Course Resources - do we publish sample answers. Example from Java Exceptions module.
Previous and next
or
Horse's mouth home
Forward to
What is a universal superclass? Java / Perl / Python / Other OO languages
Some other Articles
Views of Melksham - November 2010
Computer Graphics is fun - even if Java Applets are Old Hat
String handling - from first steps to practical examples
What is a universal superclass? Java / Perl / Python / Other OO languages
Java Beans, tag libraries and JSPs - what and why.
After Course Resources - do we publish sample answers. Example from Java Exceptions module.
Changing a Servlet - more that just editing and compiling
Gathering information - logging - with log4j. First steps.
Least Common Ancestor - what is it, and a Least Common Ancestor algorithm implemented in Perl
Java - basic rules for arithmetic, variables and conversion
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/3046_Jav ... -why-.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb