Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
256
Chapter 11 The JSP page Directive: Structuring Generated Servlets
Listing 11.4 shows a page that uses this approach; Figures 11 7 and 11 8
show the results in Internet Explorer. Again, in a real application the data
would almost certainly be dynamically generated. For example, see Section
18.3 (Some JDBC Utilities) for some very simple methods to create an HTML
table (usable in HTML or as an Excel spreadsheet) from a database query.
Listing 11.4 ApplesAndOranges.jsp
Comparing Apples and Oranges
HREF="JSP Styles.css"
TYPE="text/css">
Comparing Apples and Oranges
<%
String format = request.getParameter("format");
if ((format != null) && (format.equals("excel"))) {
response.setContentType("application/vnd.ms excel");
}
%>
| Apples | Oranges
First Quarter | 2307 | 4706
Second Quarter | 2982 | 5104
Third Quarter | 3011 | 5220
Fourth Quarter | 3055 | 5287
|
---|
|
---|
|
---|
|
---|
|
---|
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved