Program: JabaDot Web News Portal

Here is perhaps the most ambitious program developed in this book. It’s the beginnings of a complete “news portal” web site, similar to,, or However (and as you should expect!), the entire site is written in Java. Or perhaps should I say “written in or by Java,” since the JSP mechanism -- which is written entirely in Java -- turns the JSP pages into Java servlets that get run on this site. The web site is shown in Figure 18-11.

JabaDot welcome page

Figure 18-11. JabaDot welcome page

Like most portal sites, JabaDot allows some services (such as the current news items and of course the ubiquitous banner ads) without logging in, but requires a login for others. In this figure I am logged in as myself, so I have a list of all available services. The page that supports this view is index.jsp (Example 18-15), which contains a hodgepodge of HTML and Java code.

Example 18-15. index.jsp

<%@page errorPage="oops.jsp"%> <HTML> <TITLE>JabaDot - Java News For Ever(yone)</TITLE> <P ALIGN=CENTER><jsp:include page="/servlet/AdRotator" flush="true"/></P> <BODY BGCOLOR="#f0f0f0"> <% HttpSession sess = request.getSession(true); User user = (User)sess.getValue("jabadot.login"); %> <TABLE> <TD WIDTH=75% ALIGN="TOP"> <!-- Most of page, at left --> <IMG SRC="logo.gif" ALIGN="LEFT"></IMG> <BR CLEAR="ALL"> <jsp:include page="./news.jsp" ...

Get Java Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.