[thelist] Using flat files instead of database for Java driven app

Hassan Schroeder hassan at webtuitive.com
Tue Feb 18 14:32:01 CST 2003


Dee, Dax Development.com wrote:

> I've not worked with JSP/Java apps that needed to read from flat files.

For simplicity's sake, nothing beats the Jakarta taglibs:

	<http://jakarta.apache.org/taglibs/>

If you're intending to read XML files, for instance something like

-- sample --
<?xml version="1.0" encoding="UTF-8"?>
<book id="USING">
   <title>TAS User Guide</title>
   <chapter id="Using1">
    <title>TAS documentation</title>
      <section>
        <title>About TAS documentation</title>
          <subsection>
            <title>Audience</title>
            <ptxt>TAS documentation is for people who need to use
                  TAS to perform actuarial modeling tasks. It is
                  also for IT professionals and network administrators
                  who are installing TAS on a local area network (LAN).
            </ptxt>
         </subsection>
      </section>
   </chapter>
</book>
-/ sample --

... the following lines in your JSP file

   <xtags:parse id="bookEntries">
     <io:request url="file:/home/projects/book.xml"/>
   </xtags:parse>
   <xtags:valueOf select="//book/title"/>

..will print "TAS User Guide" .

Tags can be nested, with the inner one's output becoming the input
to the enclosing one; example:

<sess:setAttribute name="bookTitle">
   <xtags:valueOf select="//book/title"/>
</sess:setAttribute>

..sets a session attribute "bookTitle" to "TAS User Guide" .

The Jakarta taglibs are pretty well documented, and easy to use,
so check 'em out :-)

HTH!
--
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.






More information about the thelist mailing list