Java Reference
In-Depth Information
Figure 18.2 A very simple page from our servlet
Figure 18.3 The servlet-generated source of our simple page
18.5
I NPUT , O UTPUT
OK, so we've dynamically created a Web pageā€”but the contents of that
page don't change. The real use for servlets comes from having them produce
dynamic content, not just from dynamically producing content.
One way for the content to be dynamic is to extract it from a database.
Using what we described in Chapter 15, you can add code to pull values from
tables in a database. Consider a query that will return multiple rows of results.
Each row could be displayed as a row in an HTML table for display on a Web
page.
Using a loop, we can generate lots of HTML with little code. This is
handy for generating HTML tables. We would likely generate the <table> tag
outside a for loop, but the <tr> and <td> tags would be output from within
Search WWH ::




Custom Search