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 and .shtml files with its PageCompile servlet. It handles the <servlet> </servlet> tag in the JSP output page as a server-side include, replacing the tag with the variable data generated by the servlet.


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:

<BEAN NAME =''quoteBean"... ></BEAN>
<INSERT bean="quoteBean" property="Quote"></INSERT>
<INSERT bean="quoteBean" property="Author"></INSERT>