Country Information system stores and displays information
about various countries and cities. It allows users to add , update, delete
and browse Country and City information. This sample demonstrates the use of
following OC4J
JSP Tag Libraries.
SQL Tags
File Upload Tags
sendMail Tag
XML transform Tag
Remarks
The SQL Custom Tag Library simplifies the coding effort required
to perform database operations from JSPs. These custom tags are prefixed with
<sql: and include dbOpen, dbClose,
dbQuery, dbCloseQuery, dbNextRow, and
dbExecute. These tags allow us to carry out database operations
from JSP page easily.
The File Upload tags supplied can be used to upload binary
files to the database or file system on the application server. The httpUploadForm
tag generates the FileUpload user interface. With the help of this tag we can
add file upload dialog box in a JSP page. The httpUpload tag processes the uploaded
content and insterts the content in a BLOB column. We can specify our own table
name or column name while uploading the contents. This sample uses these file
upload tags to upload the map images of the Countries and Cities.
The sendMail tag allows us to send email through JSP pages.
We must specify SMTP host, sender, recepient , subject and mail body. This sample
uses the sendMail tag to send mail containing Country and City information.
XML transform tag allows us to apply XSL stylesheets. We may
retrieve query output as an XML document and then apply necessay stylesheets
to create output in desired format. This sample uses the tranformation tag to
transform XML ouput from SQL Tags to HTML and WML formats.
Code from InsertCountry.jsp
...
<!-- Get required information from request header. --> <P> Name : <%= request.getParameter("cname") %><br> Currency : <%= request.getParameter("currency") %><br> Continent: <%= request.getParameter("continent") %><br> Climatic : <%= request.getParameter("climatic") %><br> Description : <%= request.getParameter("description") %><br> Map Name : <%= request.getParameter("mapname") %><br> Flag Name : <%= request.getParameter("flagname") %><br> <HR> <!-- Insert country record. -->
... <sql:dbOpen commitOnClose="true" dataSource="jdbc/PooledOTN9iDS"> <sql:dbExecute output="yes"
bindParams="cname currency continent climatic description
mapname flagname">
INSERT INTO CIS_COUNTRIES (COUNTRY_ID,NAME,CURRENCY,CONTINENT,CLIMATE_ZONE,
DESCRIPTION,MAPNAME,FLAGNAME)
VALUES (seq_countries.nextval,?,?,?,?,?,?,?) </sql:dbExecute> </sql:dbOpen>
...