Database Reference
In-Depth Information
<html>
<head><title> Tables in cookbook Database </title></head>
<body>
<p> Tables in cookbook database: </p>
<sql:query dataSource= "${conn}" var= "rs" >
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'cookbook' ORDER BY TABLE_NAME
</sql:query>
<c:forEach items= "${rs.rowsByIndex}" var= "row" >
<c:out value= "${row[0]}" /><br />
</c:forEach>
</body>
</html>
The taglib directives identify which tag libraries the page uses, and the include di‐
rective pulls in the code that sets up a data source for accessing the cookbook database.
The rest of the script generates the page content.
Assuming that you've installed the mcb.war file in your Tomcat server's webapps direc‐
tory as described earlier, you should find the show_tables.jsp script in the mcb subdir‐
ectory. Request it from your browser as follows:
http://localhost:8080/mcb/show_tables.jsp
The JSP script does not produce any Content-Type: header explicitly. The JSP engine
produces a default header with a content type of text/html automatically.
18.4. Encoding Special Characters in Web Output
Problem
Certain characters are special in web pages and must be encoded if you want to display
them literally. Because database content often contains instances of these characters,
scripts that include query results in web pages should encode those results to prevent
browsers from misinterpreting the information.
Solution
Use the methods provided by your API for performing HTML-encoding and URL-
encoding.
Search WWH ::




Custom Search