Quote of the Day Sample

This sample reads a file of familiar (or not-so-familiar) quotes and displays a new quote each time the page is requested. It's an easy way to add dynamic interest to your web site.

Run this sample

 


How this sample works:

This sample has:

  • A Java servlet that reads a flat file of text strings, loads them into a bean, and then finds the next string.
  • A Java Server Page (JSP) that invokes the servlet and displays the data from the bean (in this case, the next quote and its author)
  • A .servlet file that provides information about the servlet to the WebSphere Application Server

The Application Server processes .jsp files with its JSP 1.0 processor servlet. The .jsp file invokes methods on the bean created by the servlet, embedding quote and author information within the output.


How to use this sample on your web page:

You can use this sample to display quotes, jokes, or even technical tips. Replace the quote.txt file with your choice of words, include the bean in your .jsp page, and insert the text and the author where you want them placed in your HTML. Refer to these tags in QuoteServletOutputPage.jsp (in the WSsamplesIDB_app/web/Quote directory under <was_root>/hosts/default_host):

<jsp:useBean id=''quoteBean"... />
java.lang.String _p0_1 = quoteBean.getQuote();
java.lang.String _p0_2 = quoteBean.getAuthor();
<P><%= _p0_1 %><P>
<P><%= _p0_2 %><P>