O'Reilly logo

Java Cookbook by Ian F. Darwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 http://www.slashdot.org, http://www.deadly.org, or http://daily.daemonnews.org. 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" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required