index [link.springer.com]978-1-4302-0736...278 index home page, for online catalog application,...

9
Index ymbols <%!... %> tags, 12 <% ... %>tags, 12 <%= ... %> tags, 13 /** ... *I Javadoc commenttags,217 accessormetllods,45-47,51,63 custom tags and, 78 Action interface, 147 defining,150 implementing, 229-232 actionClass variable, 227,240 actions, 147 creating, 152 factory for building, 151, 227 mapping to requests, 148 testing, 192 addtocart.giffile, 249 Ant, 199 application framework deployment via, 237-240 automating software builds via, 203-212 for online catalog application, 273 integrating CVS via, 207 Apache Jakarta Project, 15 Apache Software Foundation Ant, 199, 202 JMeter tool, 195 log4j package, 218 Struts framework, 216 app.props property file, 246 application constants, 220, 246 application frameworks, 215-240 adding unit tests to, 192 building, 216-237 deploying,237-240 designing, 215-217 vs. development framework, 200 request-handling framework, adding to, 227-232 required characteristics of, 216 using,240 application resources, creating for online catalog application, 249 application servers, 3 choosing, 15 J2EE and, 4-6 precompiling JSP pages and, 209-211 setting up for online catalog application, 244 applications building healtll insurance quoting system and, 18-22,108 online catalog and,241-273 repeatable process for, 199 surveysystemand,108-111,149-164 components comprising, 3 deployment techniques for, 199-213 developing, 1-9 patterns for, 6-9 development process for, managing, 200-203 testing for performance, 194 attribute element, 80 autllenticating users, 224-227, 250-252 @autllor field, 217 automated unit tests, 188 batch files, software testing and, 202 BEA WebLogic application server, 4, 15 BeanPopulateTag, 94 behaviors, 147 best practices, 103. See also design patterns body-content element, 80 body content, processing, 82-87 body tags, 83-87 BodyTag interface for, 76 BodyTag interface, 76 implementing, 82 BodyTagSupport class, 76 extending, 82 bug-tracking systems, 203 build scripts. See scripts bulleted lists, creating, 182-186 business tier, 104 Bugzilla tool, 203 cache of records, 50 populating, 52, 57 cart.jsp file, 271-273 CartAction class, 265-268 CartBean class, 268-271 catalog sample application. See online catalog sample application 275

Upload: duonganh

Post on 28-Jul-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

Index

ymbols <%!... %> tags, 12 <% ... %>tags, 12 <%= ... %> tags, 13 /** ... *I Javadoc commenttags,217

accessormetllods,45-47,51,63 custom tags and, 78

Action interface, 147 defining,150 implementing, 229-232

actionClass variable, 227,240 actions, 147

creating, 152 factory for building, 151, 227

mapping to requests, 148 testing, 192

addtocart.giffile, 249 Ant, 199

application framework deployment via, 237-240

automating software builds via, 203-212

for online catalog application, 273 integrating CVS via, 207

Apache Jakarta Project, 15 Apache Software Foundation

Ant, 199, 202 JMeter tool, 195 log4j package, 218 Struts framework, 216

app.props property file, 246 application constants, 220, 246 application frameworks, 215-240

adding unit tests to, 192 building, 216-237 deploying,237-240 designing, 215-217 vs. development framework, 200 request-handling framework, adding to,

227-232 required characteristics of, 216 using,240

application resources, creating for online catalog application, 249

application servers, 3 choosing, 15 J2EE and, 4-6

precompiling JSP pages and, 209-211 setting up for online catalog application, 244

applications building

healtll insurance quoting system and, 18-22,108

online catalog and,241-273 repeatable process for, 199 surveysystemand,108-111,149-164

components comprising, 3 deployment techniques for, 199-213 developing, 1-9

patterns for, 6-9 development process for, managing,

200-203 testing for performance, 194

attribute element, 80 autllenticating users, 224-227, 250-252 @autllor field, 217 automated unit tests, 188

batch files, software testing and, 202 BEA WebLogic application server, 4, 15 BeanPopulateTag, 94 behaviors, 147 best practices, 103. See also design patterns body-content element, 80 body content, processing, 82-87 body tags, 83-87

BodyTag interface for, 76 BodyTag interface, 76

implementing, 82 BodyTagSupport class, 76

extending, 82 bug-tracking systems, 203 build scripts. See scripts bulleted lists, creating, 182-186 business tier, 104 Bugzilla tool, 203

cache of records, 50 populating, 52, 57

cart.jsp file, 271-273 CartAction class, 265-268 CartBean class, 268-271 catalog sample application. See online

catalog sample application 275

276

catalog sample database, 50 CatalogBean, 255-259 Catalogltem tag, 259, 260

handler for, 261-265 census sample application, 108-111

request -handling framework, adding to, 149-164

census.jsp file, 108, 116-118 modifying for login/ submit actions, 162

change management, 203 child tags, 87 class definitions, documenting, 217 class-level variables, documenting, 217 code reviews, 201 command objects. See actions comments, adding to application

frameworks, 217 common elements, storing in a single file,

28-33 Concurrent Versions System. See CVS condition task (Ant), 212 confirmation page, 108, 119 content, separating from presentation, 45,

106. See also role separation controller (in MVC), 108, 143

building,120-124,158-161 JSP page vs. servlet for, 145

copy task (Ant),204 using cvs task instead of, 207

createAction method, 151 creating

actions, 152 application frameworks, 216-237

script for deploying, 237-240 applications

online catalog and, 241-273 health insurance quoting system and,

18-22 surveysystemand,108-111,149-164

controller (inMVC), 120-124,158-161 custom tags, 78-82 CustomerBean, 63-68 database helper, 220-223 databases, for online catalog, 242-244 error page, for online catalog, 249 filter classes, 128-130 hyperlinks, lists of, 178-182 JavaBeans, 46, 63-68 JSP pages, 68-72 lists, 182-186 login action, 152 navigational links, 58-61 menus, 178-182 request helper, 149 static resources, for online catalog, 249 tag handlers, 78-80 tag library descriptors, 80, 169

currency formatting, 171-177, 233-237 online catalog application and, 271, 273

custom tags creating, 78-82 helpers implemented as, 169 menus and, 179 nesting, 87-92 role separation and, 75-101 using in JSP pages, 81

Customer Bean adding methods to, 111-114 creating, 63-68 modifying for user ID/status fields, 155

CVS (Concurrent Versions System),201, 206-208

integrating via Ant, 207 cvs task (Ant), 206,207

daemons,3 data

committing to database, 63 form. See form data, processing handling large sets of, 49-61 validatingviaJavaBeans, 61-74

testing for, 72 database helper, building, 220-223 database servers, 3

connecting to, 20 databases

catalog sample database, 50 choosing, 16 creating, for online catalog application,

242-244 DataSources

application constants and, 220 application server configuration and,

109-111 datatype conversions, for JavaBeans, 48 date formatting, 171-177, 233-237 debug statements, 218 DecimalFormat class, 173 declarations, 11, 12 Decorating Filter pattern, 106, 125-141. See

also filters applying, 128-141 strategies for, 126

deployment techniques, 199-213 design patterns, 103-106

reasons for using, 103 destroy method, 128, 133 development environment

setting up, for online catalog application, 24 7 choosing, 15

development framework, 200 development process, managing, 200-203 directives, 11

Dispatcher pattern, 106 doAfterBody method, 83

while loop and, 95 doBody tag, 101 documenting applications, 217, 273 doEndTag method, 78 doFiltermethod,128

requests and, 133 responses and, 135, 136

doGet method controller servlet and, 146 vs. doFilter method, 128

doPost method controller servlet and, 146 vs. doFilter method, 128

doStartTag method, 78, 83 while loop and, 95

downloads Ant,203 CVS,206 JDBC drivers, 18 jEdit, 15 ]Meter tool, 195 JSTL, 16 JUnit tool, 189 MySQL database server, 16 sample code for this book, 19

liE EJB containers, 4, 6 EL expressions, 11, 13 empty tags, Tag interface for, 76 endless loops, 83 Enhydra application server, 4 errorhandlin~25-28

form data and, 61, 63, 68 errormessages,218

failed login and, 250 error pages, creating, 25

for online catalog application, 249 errorPage directive, 26 errors hashtable, 63 errors object, 68 exception object, 26 exceptions. See error handling execute method, 150, 152 Expression Language ( EL expressions), 11, 13 expression tag, 13 expressions, 11, 13 eXtensible Markup Language. See XML

Factory pattern, 104 request-handling behaviors and, 147

files, including in JSP page, 28-33 filter classes, creating, 128-130 filter managers, 126

filters, 126-128 applying, 128-141

<;INDEX 277

custom, for Decorating Filter pattern, 126 declaring, 130 Front Controller pattern and, 165 mapping to url, 130 Server objects vs. HTTPServlet objects

and,128 findAncestorWithClass method, 87 font tag, 63, 68 footer, storing in JSP page, 28 form data, processing, 33-36, 61

ways to standardize, 61-74 formattext helper, 171-177 FormatTag class, 173-177, 233-237

online catalog application and, 271, 273 formatValue method, 173 forward tag, 37 Front Controller pattern, 106,143-165. See

also controller (in MVC) applying, 149-165 filters and, 165 JSP page vs. servlet for, 145 strategies for, 144-149

• GET requests, 2 getAction method, 149 getEnclosingWriter method, 83 getListmethod,181 getModel method, 150 getParameterNames method, 34 getParent method, 87 getProperty tag, 4 7 getlleadermethod,83 getString method, 83 getView method, 150 getWriter method, 136 gif files, for online catalog application, 249

grocery order sample nested tags, 87-92

~H hdr_bar.gif file, 249 headers/footers, storing in JSP pages, 28

for online catalog application, 249 health insurance quoting system sample

application,18-22,108 servlet for, 42-44

helpers, 167-186 advantages of, 168 implementing

as custom tags, 169 asJavaBeans,168

for lists, 182-186 for menus/lists ofhyperlinks, 178-182 page designers and, 168, 170 for text formatting, 171-177

278 INDEX

home page, for online catalog application, 252-255

Catalogltem tag and, 259 HTML (HyperText Markup Language), 6 HtmlUtils tag handler, 84-86 HTTP (HyperText Transfer Protocol), 1-3 HTTP requests, 2

filters for, 125, 130-135 handling,4 life cycle of, 144

HTTP responses, 2 filters for, 125, 135-141

HttpServletResponseWrapper, 136 HttpSession object, 39 hyperlinks, creating lists of, 178-182 HyperText Markup Language (HTML), 6 HyperText Transfer Protocol (HTTP), 1-3

IBM WebSphere application server, 4 IDE (Integrated Development Environment),

15 if loop, imitating via BeanPopulateTag, 94 images, for online catalog application, 249 include directive, 11,30

frequently changing files and, 32 include tag, 37 includes, 100 infinite loops, 83 info element, 80 information messages, 218 init method, 128, 132 insurance quoting system. See health

insurance quoting system sample application

Integrated Development Environment (IDE), 15

integration tier, 104 Intercepting Filter pattern. See Decorating

Filter pattern

'"':.I J2EE,4-6

development environment and, 15 web application deployment structure

and,6 J2EE patterns, 9 J2EE Patterns Catalog, 103, 104

resource mapping strategies and, 148 JAR files (Java Archive files), 217,236,237

online catalog application and, 273 jar tag, 204 Java Archive files. See JAR files Java Message Service (JMS), 4 Java Naming and Directory Interface (JNDD,

4 Java Server Pages (JSP). See entries atJSP

Java Servlet 2.4 API, standard filters and, 127 applying, 128-141

Java servlets. See servlets JavaSwingAPI, 107 Java Transaction API (JTA), 4 Java VIrtual Machine (NM), 5 JavaBeans, 45-49

as model in MVC, 111 building,46,63-68 helpers implemented as, 168 ProductBean(sampleJavaBean),51,57-61 properties of, accessing, 47-49 using within JSP, 45-7 4

javac tag, 204 javadoc task, 237 Javadoc tool, 217

online catalog application and, 273 javax.servlet.Filter interface, 128 JBoss application server, 4, 15 JDBC drivers, 18 JDBC technology, 4 jEdit development tool, 15 JMeter tool, 187, 195 JMS (Java Message Service), 4 JNDI (Java Naming and Directory Interface),

4 JSP (Java Server Pages), 6, 9. See also JSP

pages EL expressions and, 13 JSTLand, 14 simple tags and, 100

JSP applications. See applications JSP model1 architecture, 7 JSP model2 architecture, 7, 8 JSP pages, 6, 9-14

building, 68-72 custom tags and, 75 designing, 19,44 Front Controller pattern and, 145 initializing/ cleaning up, 41-44 JavaBeans and, 45-74 modifying for login/ submit actions, 161 precompiling,209-211 quick reference card for, 23 refining, 93-99 storing common elements in, 28-33 using fragments of within other JSP pages,

100 JSP Standard Tag Library (JSTL), 14

dowriloading/ installing, 16 jsp-version element, 80 jspBook.xml, 110 jspc task (Ant), 211,212 jspDestroy method, 10

overriding, 12 jsplnit method, 10

overriding, 12

jspService method, 10 scriplets and, 12

JspWriter, 78, 83 JSTL (JSP Standard Tag Library), 14

downloading/ installing, 16 JTA (Java Transaction API), 4 ]Unit tool, 189-191 JVM (Java Virtual Machine), 5

layers (of presentation logic), 105 lifecycle methods ofTag/BodyTag interfaces,

76 listeners, 3 lists, creating, 182-186 load testing, 187, 194 log files, requests/responses written to,

139-141 logging messages, 218 Logical Resource Mapping strategy, 149 login

failed, status message for, 250 for online catalog application, 250-252 simplifying via Decorating Filter pattern,

125-141 login action

creating, 152 testing, 192

login.jsp file (login page), 108, 114 modifying for login/ submit actions, 161 online catalog application and, 250-252 requests and, 139

logo.gif file, 249 loops, 83

t:N make utility {Unix), 199, 202 menus, creating, 178-182 methods

documenting, 217 writing tests for, 191

Microsoft Visual SourceSafe, 201

Ant tasks for, 206 Wmdows, path names and, 212

MIME types, 2 mkdir task {Ant), 204 model (inMVC), 111-114 model data, 167 model separation strategy, 170 Model-View-Controller (MVC architecture),

8, 106-124 Multiplexed Resource Mapping strategy, 149 MVC architecture, 8, 106-124 MySQL Connector/] driver, 18 MySQL database server, 15, 16

connecting to, 20

iiNDEX 279

... name element, 80 naming conventions, for JavaBeans, 47 navigational links

creating, 58-61 modifying,97

nesting tags, 87-92 NextRowTag, 95

0 Object-Oriented programming {00

programming), 6 design patterns and, 103

online catalog sample application, 241-273 build script for, 24 7, 248

running, 273 catalog in, viewing, 252-265 designing, 241 logging into, 250-252 setting up, 242-250 shopping cart in, accessing, 265-273

00 programming, 6 design patterns and, 103

open-source tools, 4, 15

• page directive, 11 for error handling, 25

page navigation, controlling, 36 pageContext object, 26 pageld variable, 224, 240 @param field, 218 param object, 26, 34 params object, 34 paramValues object, 34 parent tags, 87 path names, 212 path task {Ant), 212 patterns. See design patterns performance, testing for, 194 Physical Resource Mapping strategy, 148 platform independence, build scripts and,

211 populate method, 57 populateFromParameters method., 111 population tag, 94 ports, 3 POST requests, 2 presentation design patterns. See design

patterns presentation tier, 103 presentation, separating from content, 45,

106. See also role presentation printRow method, 261 processing form data, 33-36 product table, 50, 242

building, 58

280 INDEX

ProductBean (sampleJavaBean), 51 using, 57-61

projects (Ant), 203 properties (Ant), 204 PVCS, Ant tasks for, 206

R reflection, 232 regression testing, 188 release method, 90 Remote Method Invocation-InterORB

Protocol (RMI-IIOP), 4 removefromcart.gif file, 249 repeatable process for software builds, 199 request-handling framework, 144

adding to application framework, 227-232 behaviors and, 147 Front Controller pattern and, 143 installing/ configuring for online catalog

application, 246 request helper and, 146, 149 strategyfor, 146 View Helper pattern and, 167

request helper, 146 building, 149

request object, JavaBeans and, 47 requests, 2

filters for, 125, 130-135 handling,4 life cycle of, 144

resource mapping strategies, 148 resource tier, 104 resources for further reading

design patterns, 103 documenting code with Javadoc, 218 JavaBean naming conventions, 4 7 javadoc task, 237 JSP, 11 Struts framework, 216 WAR files, building with Ant, 209

responses, 2 filters for, 125, 135-141

@return field, 218 RMI-IIOP (Remote Method Invocation­

InterORB Protocol), 4 role separation

via custom tags, 75-101 helpers and, 168 viaJavaBeans,45-74 in online catalog application, 24 7

• sample applications health insurance quoting system, 18-22,

108 online catalog, 241-273 survey system, 108-111, 149-164

sample code for this book, downloading, 19 scriplets, 11

reasons for not using, 12 scripts

for application framework deployment, 237-240

for online catalog application, 24 7 running,273

for software builds, 203-212 software testing and, 188, 202 startup, modifying for application server,

247 security, servlets and, 42 Serializable interface, 45, 51 servlet container, custom tags and, 75 servlet controller. See controller (in MVC) servlet model, 7 ServletContext object, JavaBeans and, 47 servlets, 5

Front Controller pattern and, 145 mapping filters to, 130 writing for database, 42-44

session management, 38-41 session object, 388

JavaBeans and, 47 setDatabase method, 150 setProperty tag, 47 setStartRow method, 57 shared resources, controller servlet and, 146 shopping cart, in online catalog application,

265-273 CartBean class for items in, 268-271 displaying, cart.jsp file for, 271-273

short-name element, 80 simple tags, 100 SimpleDateFormat class, 173 @since field, 217 sniffers, 130 software testing. See testing source control, 201

integrating build scripts into, 206-208 Starbase StarTeam, 201

Ant tasks for, 206 startup script, modifying for application

server,247 state, maintaining, 38-41 static resources, creating for online catalog

application, 249 Struts framework, 216 submitaction,152,154 submit method, 63, 112 Sun Microsystems' JSP quick reference card, 23 survey page, 108,116-118 survey sample application, 108-111

request -handling framework, adding to, 149-164

switch statement, 261

table tag, 87 tag-class element, 80 tag elements, 80 tag handlers, 75-82

building, 78-80 for Catalogltem, 261-265 locating, 76

Tag interface, 76 implementing, 78-80

tag library descriptors (TLDs), 80 body tags and, 84 for Catalogltem tag, 260 creating, 80, 169 declaring, 81 for lists, 182 for menus, 180

taglib directive, 12, 169 JSTLand, 14 tag handlers and, 76

TagSupport class, 78 targets (Ant), 203, 237 tasks (Ant), 204,237 TCP/IP (Thansmission Control

Protocol/Internet Protocol), 2 td tag, 87 template text, 11, 20 test fixture, 189 testing, 187-197

actions, 192 applications, for performance, 194 reasons for, 187

thankyou.jsp file, 108, 119 modifying for login/submit actions, 164

thread groups, 195 TLDs. See tag library descriptors tlib-version element, 80 Tomcat serve~ 15

online catalog application and, 244 precompiling JSP pages and, 210, 211

tools. See utilities trtag, 87 Thansmission Control Protocol/Internet

Protocol (TCP/IP), 2 tstamp tag, 204

UI components (user interface components), 233-237

uid variable, 224, 240 ul tag, 182 unit tests, 188

framework for, 189-194 Unix

build scripts and, 205 make utility and, 199, 202 path names and, 212

uri element, 80, 236 URL pattern, mapping filters to, 130 use bean tag, 4 7 user interface components (UI components),

233-237 user table (online catalog sample

application), 242 users, authenticating, 224-227,250-252 utilities

Bugzilla, 203 Javadoc, 217,273 jEdit, 15 JMeter, 187, 195 JUnit, 189-191 log4j, 218 open-source, 4, 15

validate method, 63, 72 validateAge method, 73 validateString method, 72 var attribute, 34 variable declarations, documenting, 217 @version field, 217 view (in MVC), 114-120 View Helper pattern, 106,167-186. See also

helpers applying, 171-186 strategies for implementing, 168-171

viewcart.giffile, 249 Visual SourceSafe (Microsoft), 201

Ant tasks for, 206

WAR files, 208 online catalog application and, 244

war task (Ant), 209 web applications. See applications Web ARchive files (WAR files), 208

online catalog application and, 244 web containers, 5

EJB containers and, 6 web servers, 3 web sites

CVS,201 J2EE Patterns Catalog, 103 JSP quick reference card, 23 web.xml. file, 6

web.xml. file, 6 body tags and, 84 controller

adding entry for, 120 mapping to, 161

database resource definition, adding to, 245

declaring tags in, 97 filter declaration, adding to, 130, 137, 246

281

282

resource entry, adding to, llO servlet declaration, adding to, 246 taglib element, adding to, 81 using application frameworks and, 240

WebLogic application server (BEA), 4, 15 WebSphere application server (IBM), 4 while loop, 84, 95 Wmdows, path names and, 212

WML (Wrreless Markup Language), JSP model2 and, 8

wrappers, HttpServletResponseWrapper and, 136

XML (eXtensible Markup Language), ll-13 Ant scripts and, 203

JOIN THE APRESS FORUMS AND BE PART OF OUR COMMUNITY. You'll find discussions that cover topics

of interest to rT professionals, programmers, and enthusiasts just like you. If you post a query to one of our

forums, you can expect that some of the best minds in the business-especially Apress authors, who all write

with The Expert's Voice™-will chime in to help you. Why not aim to become one of our most valuable partic­

ipants (MVPs) and win cool stuff? Here's a sampling of what you'll find:

DATABASES

Data drives everything. Share information, exchange ideas, and discuss any database programming or administration issues.

INTERNET TECHNOLOGIES AND NETWORKING

Try living without plumbing (and eventually 1Pv6). Talk about networking topics including protocols, design, administration, wireless, wired, storage, backup, certifications, trends, and new technologies.

JAVA

We've come a long way from the old Oak tree. Hang out and discuss Java in whatever flavor you choose: J2SE, J2EE, J2ME, Jakarta, and so on.

MAC OSX

All about the Zen of OS X. OS X is both tihe present and tihe future for Mac apps. Make suggestions, offer up ideas, or boast about your new hardware.

OPEN SOURCE

Source code is good; understanding (open) source is better.

Discuss open source technologies and related topics such as PHP, MySQL, Linux, Peri, Apache, Python, and more.

HOW TO PARTICIPATE:

PROGRAMMING/BUSINESS

Unfortunately, it Is. Talk about tihe Apress line of books tihat cover software metihodology, best practices, and how programmers interact witih tihe "suits."

WEB DEVELOPMENT/DESIGN

Ugly doesn't cut it anymore, and CGI is absurd. Help is in sight for your site. Find design solutions for your projects and get ideas for building an interactive Web site.

SECURITY

Lots of bad guys out there-the good guys need help. Discuss computer and network security issues here. Just don't let anyone else know tihe answers!

TECHNOLOGY IN ACTION

Cool things. Fun things. lfs after hours. It's time to play. Whetiher you're into LEGO® MINDSTORMS™ or turning an old PC into a DVR, tihis is where technology turns into fun.

WINDOWS

No defenestratlon here. Ask questions about all aspects of Windows programming, get help on Microsoft technologies covered in Apress books, or provide feedback on any Apress Windows book.

Go to the Apress Forums site at http://forums.apress.com/.

Click the New User link.