CODEFETCH™
            Examples
Cache of jstlsample/web/jstlbook.jsp from
http://books.elsevier.com/companions/0126567557/software/jstlsample.zip
Source code below from:
JSTL : Practical Guide for JSP Programmers (The Practical Guides)
By Sue Spielman
Published 22 August, 2003
Average rating

      Powells     Alibris


<%@ include file="globals.jsp" %>
<html>
<head>
<title>
<c:out value="JSTL Practical Guide Book Samples"/>
</title>
</head>
<body>
<h1>
<c:out value="JSTL Practical Guide Book Samples" />
</h1>
<h2>Application setup</h2>
<P>There is a readme.txt file that you should read before running the files below. The readme.txt file
is in the root directory of your download.
</P>
<p>In order to use the samples in the chapters, you must first run the databaseinit.jsp.
This will set up tables and populate the data used in the samples. This data matches that shown throughout
the book. If you are using a database other then MySQL, you will need to change the driver and url to the database
you are working with. No user/password is required to run the samples.</p>
<p><a href="databaseinit.jsp">databaseinit.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/databaseinit.jsp"/>
          </c:url>"
       />view source</a>)

 - uses the MySql driver&nbsp;
to set up tables and populate it with data for use with all of the samples.
Note: you will need to change the driver and url if you are using a different
database to run the samples.</p>

<br>
<p><a href="databaseinitconfig.jsp">databaseinitconfig.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/databaseinitconfig.jsp"/>
          </c:url>"
       />view source</a>)
- uses configuration settings
from the web.xml to set the datasource. </p>
<p><a href="cleandatabase.jsp">cleandatabase.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/cleandatabase.jsp"/>
          </c:url>"
       />view source</a>)
- Remove all data from the books table in the database. Running this
file requires that you have DELETE priviledges on the 'book' table. Otherwise you will get an access denied error. </p>
<h2>Chapter 1</h2>
<p><a href="hello.jsp">hello.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/hello.jsp"/>
          </c:url>"
       />view source</a>)
- Hello My Friend sample using scriplet code</p>
<h2>Chapter 3 - Using the Expression Language</h2>
<p><a href="operators.jsp?name=Sue&month=9">operators.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/operators.jsp"/>
          </c:url>"
       />view source</a>)
Various ways to use EL operators</p>
<p><a href="coersion.jsp?month=9">coersion.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/coersion.jsp"/>
          </c:url>"
       />view source</a>)
Show how coersion works</p>
<p><a href="coersion.jsp?month=September">coersion.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/coersion.jsp"/>
          </c:url>"
       />view source</a>)
Show how coersion works when a value can't be coerced</p>
<h2>Chapter 4 - Working with the Core tag library</h2>
<p><a href="cout.jsp">cout.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/cout.jsp"/>
          </c:url>"
       />view source</a>)
- Various uses of the &lt;c:out&gt; action</p>
<p><a href="cset.jsp?name=Sue&areacode=303&number=555-1212&ext=2066">cset.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/cset.jsp"/>
          </c:url>"
       />view source</a>)
- Various uses of the &lt;c:set&gt; action</p>
<p><a href="cremove.jsp">cremove.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/cremove.jsp"/>
          </c:url>"
       />view source</a>)
- Using the &lt;c:remove&gt; action</p>
<p><a href="ccatch.jsp">ccatch.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/ccatch.jsp"/>
          </c:url>"
       />view source</a>)
- Using the &lt;c:catch&gt; action</p>
<p><a href="pagingdemo.jsp">pagingdemo.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/pagingdemo.jsp"/>
          </c:url>"
       />view source</a>)
- Show how to page using a loop</p>
<p><a href="cforeach.jsp">cforeach.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/cforeach.jsp"/>
          </c:url>"
       />view source</a>)
- Show how to loop over collections</p>
<p><a href="cfortokens.jsp">cfortokens.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/cfortokens.jsp"/>
          </c:url>"
       />view source</a>)
- Show how to tokenize</p>
<p><a href="cimport.jsp">cimport.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/cimport.jsp"/>
          </c:url>"
       />view source</a>)
- Various uses of the &lt;c:import&gt; action</p>
<p><a href="cimportabs.jsp">cimportabs.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/cimportabs.jsp"/>
          </c:url>"
       />view source</a>)
- Using an absolute url with the &lt;c:import&gt; action. Note: you need an live internet connection for this to complete sucessfully.</p>
<p><a href="cimportcontext.jsp">cimportcontext.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/cimportcontext.jsp"/>
          </c:url>"
       />view source</a>)
- Importing from another context using the <c:import> action. Note: Make sure you have the context configured in Tomcat's server.xml file.</p>
<p><a href="cimportvar.jsp">cimportvar.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/cimportvar.jsp"/>
          </c:url>"
       />view source</a>)
- Importing using var and varReader with &lt;c:import&gt; action</p>
<p><a href="credirect.jsp">credirect.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/credirect.jsp"/>
          </c:url>"
       />view source</a>)
- Using the &lt;c:redirect&gt; action</p>
<p><a href="pagingdemoURL.jsp">pagingdemoURL.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/pagingdemoURL.jsp"/>
          </c:url>"
       />view source</a>)
 - Show how to page using a loop with &lt;c:url&gt; and &lt;c:param&gt;</p>
<p><a href="curl.jsp">curl.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/curl.jsp"/>
          </c:url>"
       />view source</a>)
- &lt;c:url&gt; with a scoped variable</p>
<h2>Chapter 5 - Working with the XML tag library</h2>
<p><a href="xparse.jsp">xparse.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/xparse.jsp"/>
          </c:url>"
       />view source</a>)
- <x:parse> using XML in body content</p>
<p><a href="xparseimport.jsp">xparseimport.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/xparseimport.jsp"/>
          </c:url>"
       />view source</a>)
- <x:parse> with an imported XML file</p>
<p><a href="xsetout.jsp">xsetout.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/xsetout.jsp"/>
          </c:url>"
       />view source</a>)
- Using <x:set> and <x:set> with an imported XML file</p>
<p><a href="xconditionals.jsp">xconditionals.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/xconditionals.jsp"/>
          </c:url>"
       />view source</a>)
- Using the various XML conditional actions with an imported XML file</p>
<p><a href="xforeach.jsp">xforeach.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/xforeach.jsp"/>
          </c:url>"
       />view source</a>)
- Iterating through an XML document</p>
<p><a href="xtransform.jsp">xtransform.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/xtransform.jsp"/>
          </c:url>"
       />view source</a>)
- Using <x:transform> with XML and XSL files</p>
<p><a href="xtransformparam.jsp">xtransformparam.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/xtransformparam.jsp"/>
          </c:url>"
       />view source</a>)
- Using &ltx:transform&gt with parameters to the XSL file</p>
<h2>Chapter 6.  Working with the  Internationalization and Formatting Actions</h2>
<p><a href="fmtsetlocaleform.jsp">fmtsetlocaleform.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/fmtsetlocaleform.jsp"/>
          </c:url>"
       />view source</a>)
- Show effects of changing locales</p>
<p><a href="fmtmessage.jsp?username=Sue">fmtmessage.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/fmtmessage.jsp"/>
          </c:url>"
       />view source</a>)
- Show how to use messages in resource bundles </p>
<p><a href="fmtsettimezoneform.jsp">fmtsettimezoneform.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/fmtsettimezoneform.jsp"/>
          </c:url>"
       />view source</a>)
- Show various ways of changing time zones</p>
<p><a href="fmtformattimestamps.jsp">fmtformattimestamps.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/fmtformattimestamps.jsp"/>
          </c:url>"
       />view source</a>)
- Show various ways of formatting timestamps</p>
<p><a href="fmtformatdatepatterns.jsp">fmtformatdatepatterns.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/fmtformatdatepatterns.jsp"/>
          </c:url>"
       />view source</a>)
 - Show various ways of formatting dates using patterns</p>
<p><a href="fmtparsedate.jsp?pubDate=06/07/03">fmtparsedate.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/fmtparsedate.jsp"/>
          </c:url>"
       />view source</a>)
- Show how to parse a date in a given format</p>
<p><a href="fmtformatnumber.jsp">fmtformatnumber.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/fmtformatnumber.jsp"/>
          </c:url>"
       />view source</a>)
- Show how to format numbers </p>
<p><a href="fmtparsenumber.jsp">fmtparsenumber.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/fmtparsenumber.jsp"/>
          </c:url>"
       />view source</a>)
 - Show how to parse numbers </p>
<h2>Chapter 7 - Working with the SQL Actions</h2>
<p><a href="displayresults.jsp">displayresults.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/displayresults.jsp"/>
          </c:url>"
       />view source</a>)
- Connects to the database
performs a query, and then demonstrates various ways to perform loops and conditionals</p>
<p><a href="displaymaxrowresults.jsp">displaymaxrowresults.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/displaymaxrowresults.jsp"/>
          </c:url>"
       />view source</a>)
- Connects to the database
performs a query limited by maxRows, and then demonstrates various ways to perform loops and conditionals</p>
<p><a href="formsample.jsp">formsample.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/formsample.jsp"/>
          </c:url>"
       />view source</a>)
 - Take some input from a form as a parameter to a query.</p>
<p><a href="formdatesample.jsp">formdatesample.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/formdatesample.jsp"/>
          </c:url>"
       />view source</a>)
- Show how to use dates from a form as a parameter to a query.</p>
<p><a href="sqlresultset.jsp">sqlresultset.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/sqlresultset.jsp"/>
          </c:url>"
       />view source</a>)
- Different ways to work with a result set.</p>
<p><a href="sqltransaction.jsp">sqltransaction.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/sqltransaction.jsp"/>
          </c:url>"
       />view source</a>)
 - Using transactions.</p>
<p><a href="sqltransactionerror.jsp">sqltransactionerror.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/sqltransactionerror.jsp"/>
          </c:url>"
       />view source</a>)
- See what happens if you use a dataSource within a transaction.</p>

<h2>Chapter 8 - JSTL Quick reference</h2>
<p><a href="implicitobjects.jsp?test=testValue">implicitobjects.jsp</a>
(<a href=
         "<c:url value="/source.jsp">
           <c:param name="filename"
                    value="/implicitobjects.jsp"/>
          </c:url>"
       />view source</a>)
- Using the implicit Objects provided in the EL</p>
<hr>
<p><a href="http://www.switchbacksoftware.com"><img border="0" src="sblogo.gif" alt="Switchback Software LLC" ></a>
<br>The
code samples provided accompany the book '<a href="http://www.amazon.com/exec/obidos/ASIN/0126567557/ref=switchbacksof-20">JSTL:
Practical Guide for JSP Programmers</a>'. Feedback, questions, comments, and/or
suggestions are always welcome. You can reach Sue at <a href="mailto:sspielman@switchbacksoftware.com">sspielman@switchbacksoftware.com</a></p>



</body>
</html>