Docstoc

INDEX

Document Sample
INDEX Powered By Docstoc
					                                      Index


Symbols                                          Account class, 400
                                                 accounts table, creating, 451
{ } (braces)                                     ActionListener interface, 164
     enclosing code blocks, 4                        Action interface and, 217
     if/else statements, use with, 9                 implementation in ScribblePane3
+ (concatenation) operator, 26                             example, 208
$ (dollar sign) character, 31                    actionPerformed( ), 52, 55, 164
     in class names, 32                          actions
. (dot) character                                    Action interface, 217
     dot operator, 12, 24, 26                        Command objects as listeners for,
     in class names, using $ instead of,                   221
            32                                       parsing, 248
* (mulitplicative) operator, 17                         ActionParser.java example, 249
/* */, enclosing comments in, 8                      reflection and, 221
// symbols, beginning comments, 5                Activatable interface, 428
= = vs. = command-line switch, 123               adapter classes, events, 204
                                                     anonymous inner classes and, 206
A                                                addDatum( ), 32
                                                 addLayoutComponent( ), 200
absolute( ) (ResultSet), 433
                                                 addMouseListener( ), 205
Abstract Windowing Toolkit (see
                                                 addMouseMotionListener( ), 205
          AWT)
                                                 addPropertyChangeListener( ), 368
AbstractAction class, using Command
                                                 addresses, InetAddress class, 87
          object, 221
                                                 addServlet( ) (DOM), 503
accept( )
                                                 add( )
   FilenameFilter object, 55
                                                     BorderLayout, 193
   ServerSocket class, 91
                                                     ComplexNumber class, 29
access control, 121
                                                 AffineTransform class, 276, 279
   AccessController class, 122
                                                     Paints.java example, use in, 285
   SecurityManager class, 122
                                                 alignment
AccessControlException, 122
                                                     Alignment class, 359
accessor methods, 28
                                                     AlignmentEditor.java, 369
   for component properties, 183
   components, bean, 356


                                           535
alphabetizing in languages, locale-         networking with, 96–98
          dependent, 148                        Who.java example, 97
AlphaComposite class, 276                   parameters, reading, 385–386
   combining colors with, 289–292           security restrictions, 375
       CompositeEffects.java example,       serialization of, 177
          290–292                           untrusted, 96
animations                              appletviewer program, 178, 385
   advanced (Hypnosis example),         applications
          305–308                           clipboard ownership, 335
   simple, 274–276                          data transfer between, 334
       BouncingCircle example, 274          GUI properties assigned by, 254
   Timer, performing in WebBrowser          RMI-based, development of, 395
          example, 234                      Swing components, commonly
anonymous inner classes, defining                   used in, 217
          event listeners, 206–208          web, 460
AnswerEvent class, defining, 364                 configuring with web.xml,
AnswerListener interface, 365                      488–490
antialiased drawing, 276–277, 287–289           deploying, 488–491
   AntiAlias.java example, 288–289              packaging into WAR files, 490
Apache Software Foundation, 459                 parsing with DOM, 502–505
   Xerces XML parser, 499                       parsing with ListServlets1,
APIDB.java (properties file), 442                   495–498
applets, 375–392                        Aqua look-and-feel (Apple), 184
   Applet class, 375                    architecture, data transfer, 334
       as containers, 182               ARCHIVE attribute (<APPLET>), 391
       methods, 376                     archives
   <APPLET> tag, 391                        JAR
       MAYSCRIPT attribute, 66                  compressed, 391
       OBJECT attribute, 177                    for applets, 391
   AppletContext class, 377, 388                JAXP package, 498
   AppletMenuBar.java example,                  Servlet API, class files, 460
          257–263                           WAR, 460, 490
   BouncingCircle example, 274          Area class, 290
   browser HTML capabilities, using     area-filling operations, converting line-
          from within, 65–68                       drawing to, 299
   clock applet, 378–380                args array, 10
   ColorGradient.java example, 273      arguments, command-line, 10
   ColorScribble program, 385               echoing, 11
   data transfer and, 335                   echoing backward, 12
   displaying, 378                      ArrayList class, 17
   FirstApplet example, 377             arrays
   FontList.java example, 271               creating, 15
   GraphicsSampler example, 267–271         length of, 11
   images and sound in, 387–391             sorting, 21
       imagemap applet, 387             ASCII characters, Unicode mappings
       Soundmap example, 388–391                   of, 142
   JAR files, 391                        atomic transactions, 450–456
   Java 1.0 event model and, 380–383    attributes, 183
       event details, 383–385               lines, specifying for, 281
       Scribble.java example, 382


536   Index
attributes (cont’d)                         customizer, defining, 371–374
    XML tags, web.xml file and, 496          customizing, 356
    (see also properties)                   defined, 354
authentication, 121                         events, 355
    message digests and digital signa-      FeatureDescriptor class, 356
            tures, 128–139                  information, specifying, 365–367
auto commit mode, 450                       installing, 360
Averager.java, 32                           interoperability of, 354
AWT (Abstract Windowing Toolkit),           methods, 355
            181                             packaging in JAR files, 359
    components                              properties, 355
       beans as, 335                        property editors, 356
       heavyweight nature of, 208               complex, defining, 369
       listing of, 183                          defining simple, 367–369
       locale property, 142                 simple, MultiLineLabel example,
    container classes, 189–190                      356–359
    displaying components, 183–188          uses of, 354
    event listeners, defining, 204           writing in JavaBeans API, 354
    graphics capabilities of Java and,   BigInteger class, 16
            266                          blocks, code, 4
    JavaBeans component model,              synchronized, 464
            event-handling API, 203      body (of code), 8
    layout managers, 190                 Boolean values, event-handling meth-
    mouse events, handling, 204–208                 ods, 381
                                         BorderLayout layout manager, 193
B                                        BorderLayoutPane program, 193
                                         BouncingCircle.java, 274
banking, remote, 396–400                 bound properties, 355
   Bank.java example, 397–400            boundaries for characters, words,
      BankingException, 397                         lines, and sentences, 148
   server for, 400–403                   Box container and BoxLayout layout
      RemoteBankServer.java, 401–403                manager, 194
BasicStroke class, 276, 281–283          boxes, DecorBox.java, 483–486
BDK (JavaBeans Development Kit),         BoxLayout class, 190
           354                           BoxLayoutPane.java, 194
beanbox program, 354                     braces (see { } under Symbols)
   installing beans, 360                 break statements, ending label code
   preparing beans for, 359                         with, 13
   property editors, 356                 BreakIterator class, 148
   YesNoPanel manipulation in, 360       BufferedImage class
beans                                       off-screen drawing in CompositeEf-
   basic concepts and terminology,                  fects example, 289
           355                              off-screen drawing, Paints.java, 285
   BeanDescriptor class, 366             BufferedImageOp interface, 292
      registering customizer with, 371   BufferedInputStream class, 45
   BeanInfo class, 356, 365              BufferedOutputStream class, 46
      YesNoPanelBeanInfo class, 366      BufferedReader class, 18, 46, 49, 64
   complex, YesNoPanel example,          BufferedWriter class, 47
           360–364                       buffering, JSP pages, 476
   custom events, 364



                                                                    Index   537
Button component, overriding actions     CharArrayWriter class, 47
          events of, 381                 charAt( ), 12
buttons                                  char-to-byte and byte-to-char convert-
   automatic creation with Action                    ers, 146
          objects, 217                   CheckedInputStream class, 45
   BorderLayout layout manager,          CheckedOutputStream class, 46
          arranging with, 193            checksums, cryptographic, 121, 128
   button box container, adding quit         (see also message digests)
          button to, 182                 ChoiceFormat class, 157
   FlowLayout manager, arranging         Cipher class, 136
          with, 191                      .class file extension, 5
   JRadioButton component, 211           class files, identifying as beans, 359
byte array buffers, 49                   classes, 24
byte streams                                 adapter classes for events, 204
   input, 45–46                              anonymous inner classes defining
   output, 46                                        event listeners, 206–208
      characters, writing to, 47             blocks of code, 4
   reading and writing, 45, 91               Class class, 161, 432
ByteArrayInputStream class, 45               class field (see fields; static fields)
ByteArrayOutputStream class, 46              containers, 189
ByteInputStream class, 45                    database, listing for, 442
byte-to-char and char-to-byte convert-       dynamic loading of, 356
          ers, 146                           externalizable, 174–176
                                             graphics, 266
C                                            hierarchy of, 24
                                             implementation of interfaces, 24
caching                                      importing, 16
   ArrayList vs. fixed-size arrays, 17        inner, events and event listeners,
   factorials, 15–16                                 211–217
Calendar class, 148                          loading remotely, 428
case: labels, 13                             methods (see static methods)
catch clauses, 15, 18–19, 420, 451           parsers, 248
centerText( ), 267                               ToolBarParser class, 251
CGI scripts, servlet advantages over,        public class, 4
          458                                reflection, using to obtain informa-
character streams                                    tion about, 161–164
   classes handling locale-specific           services, loading from URL, 123
          encodings, 146                     stub and skeleton, generating, 400
   filtering, 62–64                           subclasses/superclasses, 24
   input, 46                                 versioning in object serialization,
   output, 47                                        176
   reading and writing streams of, 45            advanced versioning, 177
characters                                   visibility levels, 24
   boundaries, locale-dependent, 148     ClassLoader class, 152
   encodings (converting locale-spe-     CLASSPATH environment variable, 6
          cific to/from Unicode),             editing to include servlet container
          146–148                                    JAR, 460
   Unicode encoding, 141–146             clear( ), 206
characters( ) (HandlerBase), 496         click and drag events, mouse, 204
CharArrayReader class, 46



538   Index
clients                                    echoing backward, 12
    Client class, 397                    command-line switches, = = vs. =, 123
    connecting to, 91                    CommandParser.java, 248
    a generic client, 99–101             commands
    MUD (multiuser domain), 420–427        parsing, 248
    remote object references, obtain-      starting server, 102
           ing, 396                      comments
    RMI, 395                               // symbols, beginning with, 5
    stubs, remotely loading, 428           doc, 8
Clipboard class, 335                       JSP, 471
ClipboardOwner interface, 335            committing transactions, auto-commit
clipping effect (CompositeEffects                 mode, 450
           example), 289                 commit( ), 450–451
Clock.java, 378–380                      CompactIntList.java, 174
closeWindow( ) (Writer), 65              comparisons of strings, locale-depen-
close( ) (Writer), 65                             dent, 148
code, untrusted                          compiler, rmic, 400
    loading, 123                         compiling, 5
    running, 122                           ListServlets1.java, 498
Collator class, 148                        ListServlets2.java, 502
ColoredRect.java, 27                       servlets, 460
colors, 272–274                            WebAppConfig example, 505
    choosing, JColorChooser compo-         WebAppConfig2 example, 514
           nent, 217                     complex numbers, 28
    color property, defining, 206         ComplexNumber.java, 28
    Color class, 272                     components, 181–188
    ColorGradient.java example, 273        adding to containers, 182
    ColorUIResource objects, 254           applets and, 378
    combining by alpha transparency        AWT (Abstract Windowing Toolkit),
           rules, 276                             181
    combining with AlphaComposite,             beans as, 355
           289–292                         Component class, 181, 183, 375
        CompositeEffects.java example,         methods, 380
           290–292                             overriding event handling meth-
    computing, GenericPaint example,              ods, 210
           303–305                         ComponentTree.java, 230–234
    SystemColor class, 273                 customizing, 257–263
    in themes, 235                             AppletMenuBar example,
    translucent (see antialiased draw-            257–263
           ing; translucent colors)            custom dialogs, 222–227
ColorScribble.java, 385–386                    JavaBeans, 356–359
ColumnLayout.java, 200–203                 drawing into, 267
combining colors (see composite col-       event handling, 182, 203–211
           ors)                            events generated by, 381
Command class, 164                         JComponent class, 183
    reflection method within, 221           layout management, 182, 190–203
CommandAction.java, 221                        BorderLayout, 193
Command.java, 164–168                          Box and BoxLayout, 194
command-line arguments, 10                     customizing, 199–203
    echoing, 11


                                                                  Index   539
components,                                    BorderLayout, 193
    layout management (cont’d)                 Box and BoxLayout, 194
       FlowLayout, 191                         customizing, 199–203
       GridBagLayout, 196–198                  GridBagLayout, 196–198
       hardcoded, 198                      preferred sizes, 200
   predefined, for low-level event          for servlets, 459
          handling, 210                        session tracking, 482
   preferred sizes, 199                 contains( ) (Shape), 295
   printing on single page, 314–319     content handlers, 84
   properties, 183                      <Context> tags, 514
   ShowComponents program,              Control class, 102
          183–188                       controlDown( ) (Event), 381
   Swing GUIs, 181                      ControlPointsStroke class, 300
composite colors                        controls, 181
   AlphaComposite class, 276,           conventions, xv
          289–292                       ConvertEncoding.java, 147
   Composite interface, 276, 289           resource bundle properties file, 159
   CompositeEffects.java example, 290   converting
compression/decompression, data            characters to bytes, 47
   Compress.java, 60–62                    locale-specific character encodings
   input and output byte streams, 45              to/from Unicode, 146–148
   JAR files, compressed, 391               text from locale-specific to Uni-
concatenation (+) operator, 26                    code, 141
configuring                              coordinate-system transformations,
   components, 183                                276, 279–281
   web applications, 488–490            copy-and-paste, data transfer
confirmation dialogs, 222                   simple, 335–338
   JOptionPane, displaying, 217                steps in process, 335
Connection class, 102, 438, 450         copy( ), 49, 344
Connection interface, 432–433              FileCopy class, 50
ConnectionManager class, 102            CORBA, interoperability with RMI/
connections                                       IIOP, 429
   client/server, establishing with     Counter servlet, 463–467
          ServerSocket, 91                 running, 467
   HttpURLConnection class, 86          counters for loops, 8
   URLConnection class, 86              countries, codes for (locales), 141
       sending email through, 87        CREATE TABLE statement, 441
   to web server, 89                    createContext( ) (GenericPaint), 303
constrained properties, 355             createPlace( ), 411
constraints (GridBagConstraints), 196   createPlafMenu( ), 184
Constructor class, 161                  createStatement( ) (Connection), 433
constructors, 24                        cryptography, 136–139
   no-argument, 356                        checksums and digital signatures,
containers, 189–190                               121
   adding components to, 182               Java Cryptography Extension (JCE),
       RootPaneContainer and, 223                 121
   Container class, 182                    public and private keys for, 128
   Containers.java program, 189–190     curly braces (see { } under Symbols)
   JFrame and JDialog, 182
   layout management, 190–203


540   Index
currency, formatting amounts for             data types for, 338–343
           locales, 148                      drag-and-drop, 334
currentSegment( ) (SpiralIterator), 296          scribbles, 347–353
currentThread ( ) (Thread), 73            data types
Customizer interface, 356, 371               char and String, Unicode encoding
customizing                                          in, 142
   bean event types, 364                     in data transfer, 334
   beans, 371–374                            integers
   components, 257–263                           BigInteger class, 16
        AppletMenuBar example,                   int, 14
           257–263                           long, 14
        hard-coded layout, 198               in object fields, 24
        JavaBeans, 356–359                   primitive
   dialogs, 222–227                              integral, in switch statements, 13
   events and event listeners, 211–217           reading/writing, ObjectInput-
   JSP tags, 483–487                                 Stream and ObjectOutput-
        defining tag, 484–486                         Stream, 169
        deployment, 486–487               DatabaseMetaData interface, 438
   layout managers, 199–203               databases
        ColumnLayout.java example,           accessing with servlets, 467–471
           200–203                           accessing with SQL, 431–457
   object serialization, 172–174                 metadata, using (GetD-
   Paint, GenericPaint example,                      BInfo.java), 438–441
           303–305                               updates, 434
   resources, 235                            atomic transactions, 450–456
   server security policy file, 122           building, 441–446
   servers, 113                                  APIDB program, 443–446
   shapes, 295–299                           connection to, 433
        Spiral.java example, 296–299         metadata, GetDBInfo program,
   strokes, CustomStrokes.java,                      438–441
           299–303                           using, 446–450
   themes, Metal look-and-feel,           DataFlavor class, 334
           253–257                           choosing in data transfer, 335
CustomStrokes.java, 299–303                  in drag-and-drop transfer, 347
cut-and-paste, data transfer, 334         datagrams
   ScribbleCutAndPaste example,              DatagramPacket class, 116
           344–347                           DatagramSocket class, 116
cut( ), 344                                  receiving, 117
                                             sending, 116
D                                         DataInputStream class, 45, 169
                                          DataOutputStream class, 46, 169
-D option (Java interpreter), setting     Date class, 86
           security manager with, 122     DateFormat class, 148–149, 157
daemon thread, 73                         dates, formatting for locales, 148–151
data transfer, 334–353                    deadlock, threads, 75–77
   architecture, 334                      Deadlock.java, 75
   copy-and-paste, simple, 335–338        declaration tags, JSP, 472
       simple, 335–338                    declarations
   cut-and-paste, 334                        package, 4, 6
       scribbles, 344–347



                                                                      Index    541
declarations (cont’d)                     device space, distinguishing from user
   version numbers for classes, 176                  space, 276
decompression, byte input streams, 46     dialog boxes
<decor:box> tag, 478, 483                    customizing, 222–227
DecorBox.java example, 483–486                   FontChooser example, 222–227
decor.tld, 486–487                           JColorChooser and JOptionPane,
decryption (see encryption/decryp-                   217
           tion)                             JDialog component, 182, 222
deepclone( ), 170                            YesNoPanel example, 360
default: labels, 13                       DigestInputStream class, 129
default security policy (from Sun), 122   digital signatures, 121, 128–139
DefaultMetalTheme class, 253                 computing, 129
defaultReadObject( ), 174                    public key cryptography, use of,
defaultWriteObject( ), 174                           128
DeflaterOutputStream class, 47             directories, compressing, 60–62
Delete.java, 48                           dispatch thread, events, 204
delete( ) (File), 48                      displaying
deploying                                    applets, 378
   custom JSP tag, 486–487                   graphics examples (GraphicsExam-
   servlets, WEB-INF/web.xml file,                    pleFrame), 308–311
           460                               property values, 367
   web applications, 488–491                 tables, 227–230
deployment descriptor, parsing with              PropertyTable example, 227–230
           ListServlets1.java, 495–498       trees, 230–234
deployment file, 463                       display( ) (LocalizedError), 147, 157
   TLD, mapping to local file copy,        doc comments, 8
           483                            Document class, 327
describing GUIs with properties,          Document Object Model (see DOM)
           242–253                        doGet( )
   GUI resources, handling basic,            Counter servlet, 463
           243–248                           HttpServlet class, 461
   parsing commands and actions, 248         Query servlet, 471
   parsing menus, 250–253                 DOM (Document Object Model)
   resources, extension mechanism            DOM Level 2, 508–512
           for complex, 248                  parsing and manipulating with,
descriptors                                          502–505
   bean features, 356                        tree, traversing, 506–508
   BeanDescriptor objects, 366            DOMTreeWalkerTreeModel.java,
   FeatureDescriptor class, 366                      508–512
   PropertyDescriptor class, 367          doPost( ) (HttpServlet), 461
   tag library descriptor, 483            double data type, 13
deserialization (see object serializa-    downloading example source code,
           tion)                                     xiv, 7
destroy( )                                drag-and-drop, data transfer, 334
   Applet class, 376                         ScribbleDragAndDrop example,
   Counter servlet, 463                              347–353
development environments, beans,          DragGestureListener interface, 347
           354                            dragGestureRecognized( ), 347
                                          dragging, mouse events, 204




542   Index
DragSourceListener interface, 347        encapsulation, 28
DrawableRect.java, 27                    encodeRedirectURL( ) (HttpServletRe-
drawImage( ) (Graphics), 387                       sponse), 482
drawing                                  encodings, characters (converting
   animation, simple, 274–276                      locale-specific to/from Uni-
   antialiasing, 287–289                           code), 146–148
       AntiAlias.java example, 288–289   encryption/decryption
   before Java 1.2, 267–276                 Java support for, 121
       GraphicsSampler example,             TripleDES algorithm, 136
          267–271                        endElement( ) (HandlerBase), 496
   custom components, handling in,       enumerated type, defining with Align-
          257                                      ment class, 359
   Graphics2D class, functions of, 266   Enumeration class, 151
   lines with area-filling operations,    environment variable CLASSPATH, 6
          299                               editing to include servlet container
   paint( ), using for, 267                        JAR, 460
   requesting particular types of, 276   equals( ), 18
   scribbles, 208                        error messages, localizing display, 157
   shapes, 277–279                       error( ) (HandlerBase), 496
       Shapes.java example, 278          event handling
   surfaces for, 314                        components, 182, 203–211
drawLine( ) (Graphics), 205                 Java 1.0 model
drawString( ) (Graphics), 378                   applets and, 380–383
draw( ), 27                                     Component class methods,
   ColoredRect class, 27                           overriding, 380
   Graphics2D class, 277                        EventTester.java, handling user
DriverManager class, 432                           events, 383–385
drivers, JDBC (see JDBC, drivers)               Scribble.java applet, 382
DropTargetListener interface, 347           Java 1.1 model, 388
drop( ), 347                                low-level, 210
DTD (document type), 498                        in custom components, 257
dynamic content generation, servlets,       mouse events, 204–208
          458                                   ScribblePane1.java example, 205
                                                ScribblePane2.java example,
E                                                  206–208
                                            SAX 1 parser, 494
-e flag, 56                               events, 380
Echo.java, 11                               AnswerEvent class, 360
   Reverse program, 11                      bean, 364, 355
editing                                     customizing, 211–217
   policy files manually, 123                Event class, 380
   property values, 368                     EventQueue class, 204
Element class, 327                          keyboard, checking id field for, 381
elements in arrays, 11                      listeners for, 368
else clauses, 9                                 EventListener interface, 203
email                                       notification, 355
   sending through URLConnection,           selection (tree node), responding
          87                                       to, 230
   SendMail.java program, 87                (see also event handling)
enableEvents( ) (Component), 210



                                                                    Index   543
Exception class, 19                      FeatureDescriptor class, 356, 366
exceptions, 15                           Fibonacci series, 10
   BankingException, 397                 Fibonacci.java, 10
   Exception class, 19                   fields
   handling, 17–19                           defined, 24
      character encoding program,            Field class, 161
          147                                instance vs. static (class), 24
   localized error messages, display-        positioning, GridBagLayout, 196
          ing, 157                           serialization (serialPersistentFields),
   RemoteException (see RemoteEx-                     reading and writing, 177
          ception)                           serialVersionUID, 176
   SQLException, 432, 434                    static, caching values in, 15
   throwing, 15, 19                          transient, declaring, 172
execute( )                                   visibility levels, 24
   PreparedStatement class, 442              writing out all values of, 169
   Statement, 434                        FileCopy.java, 50–51
executeQuery( )                          FileDescriptor class, 172
   PreparedStatement class, 442          FileInputStream class, 45, 49
   Statement class, 433                  FileLister.java, 55–60
ExecuteSQL.java, 433–438                 FilenameFilter class, 55
executeUpdate( )                         FileOutputStream class, 47, 49
   Prepared Statement class, 442         FileReader class, 46, 52
   Statement class, 433                  files
expressions, JSP, 478                        content handlers, text and image
   tags for, 472                                      formats, 84
extends keyword, 27                          data transfer, 334
Extensible Markup Language (see              File class, 44, 48–49
          XML)                               FileCopy class, 50
externalizable classes, 174–176              input/output, 48–62
Externalizable interface, 174                    compressing, 60–62
                                                 copying contents of, 49–51
F                                                deleting, 48
                                                 listing directory and file infor-
FactComputer.java, 18                                 mation, 55–60
Factorial2.java, 14                              text files, reading and display-
Factorial3.java, 15                                   ing, 52–55
Factorial4.java, 17                          RandomAccessFile class, 44
Factorial.java, 14                           selection, JFileChooser, 222
factorials, 13–19                            serialized applets (.ser extension),
    caching, 15–16                                    178
    computing, 13–17                     FileViewer.java, 52–55
       big, 16                           FileWriter class, 47
       interactive input, 18             filling shapes, 277–279
    exception handling, 17–19                with Paint, 284–287
    recursive, 14                            shapes.java example, 278
factorial( ), 13, 17                         stroked, 283
FactQuoter.java, 19                      fill( ) (Graphics2D), 277
false values, return by event-handling   filtering
           methods, 381                      character streams, 62–64
fatalError( ) (HandlerBase), 496



544   Index
filtering (cont’d)                       G
    lines of text, 64
FilterInputStream class, 45             GeneralPath class, 300
FilterOutputStream class, 47            generic client, creating, 99–101
FilterReader class, 46, 62              generic multithreaded server, creating,
FilterWriter class, 47                           101–113
filter( ) (BufferedImageOp), 293         GenericPaint.java, 303–305
finally statement, 49, 52                GET requests, HTTP, 89
finger service, 96–98                       counter name, determining for dis-
FirstApplet.java, 377                            play, 463
first( ) (ResultSet), 433                   providing response, Hello servlet,
FizzBuzz games, 7–9                              461
FizzBuzz2.java, 12                      getAppletContext( ), 377
FizzBuzz.java, 8                        getAppletInfo( ), 385
flavors, data transfer, 334                 Applet class, 376
    choosing, 335                          Clock class, 378
    problems with, 335                  getAsText( ), 367
flickering, animations, 274              getAudioClip( ), 388
    eliminating, 305                       Applet class, 376
FlowLayout layout manager, 191          getBundle( ) (ResourceBundle), 151
FlowLayoutPane program, 191             getCodeBase( ), 377
flush( ) (Writer), 65                    getColor( ), 206
fonts, 271                              getComponentsFromArgs( ), 184
    font glyphs as Shape objects, 285   getConnection( ) (DriverManager),
    FontChooser custom dialog,                   432–433
           222–227                      getContent( ) (URL), 84
    FontList.java example, 271          getContents( ), 335
    FontUIResource objects, 254         getContentPane( ), 223
    Java 2D API, 276                    getCustomEditor( ), 368, 370
    in themes, 235                      GetDBInfo.java, 438–441
    Unicode character display, 142      getDefault( ) (Locale), 142
for loops, 7                            getDocumentBase( ), 377, 387
    nested, 11                          getElementsByTagName( ) (DOM), 503
    syntax, 8                           getEntrance( ) (RemoteMudServer),
    written as while loops, 11                   420
forcelogin.jsp example, 477             getHSBColor( ) (Color), 272
format( ) (MessageFormat), 157          getImage( ), 387
forName( ) (Class), 162, 432               Applet class, 376
forwarding requests, 476                getInputStream( )
    <jsp:forward> tag, 476                 ServerSocket class, 91
frames (see windows)                       Socket class, 89
fully qualified names                    getJavaInitializationString( ), 368
    classes, 442                        getKeys( ), 151
    programs, specifying for, 7         getMetaData( ) (Connection), 438
FunnyMoney class, 397                   getNamedPlace( ) (RemoteMudServer),
                                                 420
                                        getNextWarning( ) (SQLWarning), 434
                                        getNumberOfPages( ), 327
                                        getObject( ), 153




                                                                   Index   545
getOutputStream( ), 87                        features of, 276
   ServerSocket class, 91                     GraphicsExampleFrame pro-
   Socket class, 89                               gram, 277
getPageFormat( ), 327                         GraphicsExample.java program,
getParameter( ), 377, 387                         277
getParameterInfo( ), 385                      image processing, 292–295
   Applet class, 376                          Paint, customizing, 303–305
getParameters( ), 385                         shapes, drawing and filling,
getParent( )                                      277–279, 284–287
   File class, 48                             strokes, custom, 299–303
   ThreadGroup class, 73                      stroking, line styles, 281–284
getPathIterator( ) (Shape), 296               transforms, 279–281
getPreferredSize( ), 198                Graphics class, 27, 266
getPrintable( ), 327                    Graphics2D class, 266, 276, 377
getRequestURI( ), 476                      compositing colors, 289
getResourceAsStream( ) (ClassLoader),   GraphicsExampleFrame.java, 308–311
          152                           GraphicsSampler.java, 267–271
getResultSet( ) (Statement), 433        GregorianCalendar class, 148
getServletClass( ), 503                 GrepReader.java, 64
getSQLState( ) (SQLException), 434      GridBagConstraints class, 196
getString( ), 152                       GridBagLayout layout manager,
getSystemClipboard( ), 335                        196–198
getTags( ), 368                            GridBagLayoutPane.java, 197
getter and setter methods, 183          GridLayout layout manager, 192
getThemeMenu( ), 254                    GUIResourceBundle
getThreadGroup( ) (ThreadLister), 73       parsing Action object from, 249
getTransferData( ), 334                    parsing Command object from, 249
getTransferDataFlavors( ), 334             theme definitions, reading from,
GetURL.java, 85                                   253
GetURLInfo.java, 86                     GUIResourceBundle.java, 243–248
getWarnings( ) (Connection), 434        GUIs, 181–265
glue, Box container layout, 194            complete, example, 217–221
go( ), 411                                 components, 181–188
GradientPaint class, 276, 285                 applets and, 378
graphical user interfaces (see GUIs)          AWT, 181
graphics, 266–313                             custom, 257–263
   animation, simple, 274–276                 events generated by, 381
   before Java 1.2, 267–276                   recomputing preferred size
       GraphicsSampler example,                   when deserialized, 173
          267–271                             Swing, 181
   color, 272–274                             (see also components)
   fonts, 271                              containers, 189–190
   Graphics class, 27, 266, 377               hierarchy of, 189
   Java 2D API, 276–311                    creating, 182
       animation, advanced, 305–308        describing with properties, 242–253
       antialiasing, 287–289                  parsing commands and actions,
       colors, combining with Alpha-              248
          Composite, 289–292                  parsing menus, 250–253
       custom shape, 295–299
       displaying examples, 308–311


546   Index
GUIs,                                       Java code, increasing separation
   describing with properties (cont’d)             from, 477
       resources, extension mechanism       JSP pages, 458
          for, 248                          tag filtration (RemoveHTMLReader
       resources, handling basic,                  program), 62
          243–248                           web browser for displaying and
   displaying tables, 227–230                      editing, 234–242
   displaying trees, 230–234             HTML files
   event handling, 203–217                  referencing applets, 377–378
       low-level, 210                          ColorScribble class, 386
   FileLister program, mechanics of,        serialized applet, creating for, 178
          55                                Soundmap class (example), 388
   Metal look-and-feel, themes and,      HTML form (portal.jsp), 478
          253–257                        HTML pages, embedding Java code in,
   simple web browser, creating,                   471
          234–242                        HTML tags
GZIP compression format, 60                 hardcoded inside Java classes, 471
gzipFile( ) (Compress), 60                  surrounding with Java scriptlets,
GZIPInputStream class, 45                          478
GZIPOutputStream class, 47, 60           HTTP
                                            GET requests, 89, 461, 463
H                                           POST requests, 461
                                         HttpClient.java, 89
handleEvent( ), 380                      HttpMirror.java, 91
handleGetObject( ), 151                  HttpServlet class, 458, 461
HandlerBase class, 496                   HttpServletRequest class, 461
handlers (see content handlers; proto-   HttpServletResponse class, 482
          col handlers)                  HttpSession class, 461, 481
hardcoded component layout, 198          HttpSessionBindingListener interface,
   NullLayoutPane.java program, 199                481
HardcopyWriter.java, 319–327             HttpURLConnection class, 86
Hello servlet, 461–463                   hyperlinks, imagemap applet example,
Hello World programs, 3–7                          387
   compiling, 5                          Hypnosis.java, 305–308
   Hello.java, 3
hierarchy                                I
   class, 24
   containment, 189                      if/else statements, 8
       displaying, ComponentTree             nested, 9
          example, 230–234                   syntax, 9
       unhandled events, passing up,     IIOP (Internet Inter-ORB Protocol),
          381                                       429
hosts, 89                                Image class, 387
   database servers, 433                 imagemaps
   mailhosts, 87                             applet example, 387
hot spots in imagemaps, highlighting,        ImagemapRectangle class, 388
          387                            ImageOps.java, 293–295
HTML                                     images
   custom output stream, 65–68               applets, loading from network, 376
       HTMLWriter.java, 66–68



                                                                    Index   547
images (cont’d)                            input streams (see input under
    buffering, 305                                      streams)
         BufferedImage class, 285, 289     input/output (I/O), 44–69
         double-buffering technique, 305       character streams, filtering, 62–64
    file formats, content handlers, 84          custom HTML output stream, 65–68
    processing, 292–295                        files, 48–62
         ImageOps.java example,                    copying contents, 49–51
            293–295                                deleting, 48
    and sounds in applets, 387–391                 and directories, compressing,
        Image class, 387                                60–62
        ImagemapRectangle class, 388               listing directory and file infor-
    tiling with, 276                                    mation, 55–60
imaginary numbers, 28                              text files, reading and display-
imaginary( ), 28                                        ing, 52–55
immutability, 28                               sequential, 44
    of strings, 19                             streams, 44–48
implementation, interfaces by classes,         text, filtering lines of, 64
            24                             InputStream class, 45, 85
import statements, 16                      InputStreamReader class, 46, 141
@include directive, 476                        byte-to-char and char-to-byte con-
    <%@include%> tag, 478                               verters, 146
include( ) (RequestDispatcher), 476        INSERT INTO statements, 441
indexed properties, 355                    installation
InetAddress class, 87                          beans, 360
infinite loops, 91                              Java Cryptography Extension (JCE),
InflaterInputStream class, 45                            136
information dialogs, displaying with           servlets, 460
            JOptionPane, 222                   Tomcat servlet container, 459
inheritance, 24                            instance fields, 24
    class hierarchy and, 27                instance methods, 24, 29
initialization                             instances, 24
    applets, shipping as preinitialized,   int data type, 14
            178                            integers
    servlets                                   array of, implementing expandable,
        Counter example, 463–467                        173
        parameters for, 463, 488               CompactIntList.java example,
initialize expression in for statements,                174–176
            8                              interactivity
initiating drag, 347                           computing factorials, 18
init( ), 387                                   Rot13Input program, 19
    Applet class, 178, 267, 376            interfaces
    Clock class, 378                           defined, 33
    ColorScribble clas, 385                    implementation of, 24
    Counter servlet, 463                   internationalization, 141–160
    drawing, problems with, 267                character encodings, convering
inner classes, 32                                       locale-specific to/from Uni-
    customizing events and event han-                   code, 146–148
            dlers, 211–217                     date, time and number formats for
input, interactive, 18                                  locales, 148–151




548   Index
internationalization (cont’d)             J
    formatted messages, 156–159
       LocalizedError.java example,       JAR (Java archive) files, 359
           157–159                            for applets, 391
    hardcoding component layout,              JAXP, 498
           problems with, 198                 Servlet API, class files for, 460
    locales, 141                          jar tool, 391
       setting, 151                       Java 1.1 Printing API, 314–316
    localizing user-visible messages,         printing multipage text document,
           151–156                                   319–327
    resource bundles, 151–156             Java 1.2 Printing API, 316–319
       SimpleMenu.java example,               PrintableDocument example,
           154–156                                   327–333
    translating user text to local lan-   Java 2D API, 266, 276–311
           guage, 141                         features of, 276
    Unicode, 141–146                          (see also graphics)
    UnicodeDisplay.java program,          Java API for XML Parsing (see JAXP)
           143–146                        Java archive files (see JAR files)
Internet Explorer, running HTMLWriter     Java code
           program, 65                        embedding within HTML pages,
Internet Inter-ORB Protocol (IIOP),                  471
           429                                increasing separation from HTML,
Internet portal (portal servlet exam-                477
           ple), 477                      Java Cryptography Extension (JCE),
interoperability, CORBA and RMI/                     121
           IIOP, 429                          downloading and installing, 136
interpreter, Java, 6                      Java Database Connectivity (see JDBC)
    invoking from any system direc-       Java drag-and-drop API
           tory, 7                            cut-and-paste API vs., 347
    passing command-line arguments            integrating with native drag-and-
           to, 10                                    drop, 347
intersects( ) (Shape), 295                .java file extension, 5
IntList.java, 173                         Java interpreter
intra-applet data transfer, 335               -D option
introspection, 161, 356                          setting security manager prop-
    GUIs, use with, 184                              erty, 122
invisible beans, 355                             specifying use of policy file, 122
invokeAndWait( ) (EventQueue), 204            system properties for security pol-
invokeLater( ) (EventQueue), 204                     icy file, specifying, 124
invoke( ) (Command), 164, 221             Java Reflection API, 221
isDaemon( ), 73                           Java Security API, 128
isDataFlavorSupported( ), 334             Java Servlet API, 458
isPaintable( ), 368                           class files, downloading, 460
ItemChooser.java, 211–217                     Java Servlet Development Kit, 459
itemStateChanged( ), 55                       (see also servlets)
iterators, breaking, 148                  Java Virtual Machine (VM)
                                              data transfer, problems with, 335
                                              servlets JAR file, path for, 460




                                                                     Index    549
java.awt package                              date and time formatting classes,
   Component class, 181                               148
       overriding mouse and keyboard          message formatting classes, 156
          event handling methods, 210      java.util package
   Graphics class, 377                        date and time formatting classes for
   graphics classes in, 266                           locales, 148
java.awt.datatransfer package, 334            internationalization classes, 141
java.awt.dnd package, 334, 347                ResourceBundle class, 151–153
java.awt.event package, 203–204            java.util.zip package, 60
java.awt.geom package, 276                    input and output byte streams,
   clipping effects, 290                              compression/decompression,
   GeneralPath class, 300                             45
   shapes, classes for, 277                javax.crypto package, 136
java.awt.image package, 292                javax.rmi package, 429
java.awt.print package, 316                javax.swing package, 181
JavaBeans, 354–374                         javax.swing.event package, 203–204
   Alignment class, 359                       ListSelectionEvent, 208
   API, 354                                javax.swing.plaf.metal package, 253
       event model, 355                    javax.swing.text package, 327
       properties, support for, 355        javax.xml.parsers package, 495
       writing beans with, 354             JAXP (Java API for XML Parsing)
   beans (see beans)                          DOM parser, obtaining with, 502
   Development Kit (BDK), 354                 downloading from Sun, 498
   event handling in component                ListServlets1.java, main( ), 496
          model, 203                          parsing and manipulating with,
   interoperability of, 354                           502–505
   introspection, 161, 356                 JButton component
       using with GUIs, 184                   Action objects, passing to construc-
   JSP pages and, 477–482                             tors, 217
javac compiler, 5, 396                        notifying listeners of mouse events,
   servlet classes and, 460                           208
javadoc program, 8                         JColorChooser component, 217
java.io package                            JComboBox component, 211
   InputStreamReader and Output-           JDBC (Java Database Connectivity),
          StreamWriter character                      431–457
          streams, 146                        drivers, 431–432
   object serialization/deserialization,          determining class name, 433
          169                                     DriverManager class, 432
   stream classes in, 45                      programming, important tech-
java.lang package, 16                                 niques, 432
java.rmi package, 395                         servlet communication with
java.rmi.registry package, 395                        database servers,, 467
java.rmi.server packages, 395                 update to version 2.0, 433
JavaScript, JSObject class, 65             JDialog component, 182
java.security package, 121                    BorderLayout as default manager,
java.sql package, 431                                 193
   interfaces in, 432                         customizing dialogs with, 222
java.text package, 141                        as RootPaneContainer, 223
                                           JDOM (Java DOM API), 494, 512




550   Index
JEditorPane component (WebBrowser               SecretKey class, representing, 136
           example), 234                     keystores, 128
JFileChooser component, 234                  keytool program, 129
JFrame component, 182, 184
    ScribblePane2 instance within, 217       L
JList component, 211
    notifying listeners of user selections   labels, 356
           from lists, 208                       HTML, displaying without JEditor-
JMenu component (ThemeManager                           Pane, 234
           example), 253                         for switch statement execution, 13
JMenuBar component, 184                          (see also MultiLineLabel.java)
    with ScribblePane 2, 217                 languages
join( ) (Thread), 71, 113                        alphabetization, locale-dependent,
JOptionPane component, 217                              148
    dialogs, displaying with, 222                codes for (locales), 141
JPanel container, 182, 189                       translating to local, 141
    FlowLayout as default layout             last( ) (ResultSet), 433
           manager, 191                      Latin-1 characters, Unicode mappings,
JRadioButton component, 211                             142
JSObject class, information about, 65        layout management, GUIs, 190–203
JSP (JavaServer Pages)                           BorderLayout, 193
    forwarding requests, 476                     Box and BoxLayout, 194
    JavaBeans and, 477–482                       customizing, 199–203
    login screen with, 471–476                       ColumnLayout.java example,
        login.jsp example, 471                          200–203
    servlets and, 458–493                        FlowLayout, 191
    tags, 471                                        FlowLayoutPane program, 191
        custom, 483–487                          GridBagLayout, 196–198
    version 1.1 specifications, 459               GridLayout, 192
<jsp:forward> tag, 476                           hardcoded layout, 198
<jsp:getProperty> tag, 477                       LayoutManager class, 182, 190
<jsp:include> tag, 476, 478                  layoutContainer( ), 199
<jsp:param> tag, 476                         LayoutManager and LayoutManager2
<jsp:setProperty> tag, 477                              interfaces, 199
<jsp:useBean> tag, 477                       length( ) (File), 48, 52
JTabbedPane component, 184                   life cycle, servlets, 463
JTable class, 227                            line boundaries, locale-dependent, 148
JTextComponent component, 327                line terminators
    displaying or editing HTML text,             differences in operating systems, 87
           234                                   \n, translating to local operating
JToolBar component, 217                                 system version, 99
JTree component, 230                         LineNumberInputStream class, 45
                                             LineNumberReader class, 46
K                                            lines
                                                 breaking
keyboard events, handling, 210, 257                  HardcopyWriter example, 319
   custom components, 257                            PrintableDocument example,
   KeyListener class, 206                               327
keyboard modifier keys, 381                       stroking, 276
keys, encryption/decryption, 128



                                                                        Index    551
lines,                                       Locale class, 141
     stroking (cont’d)                       locales
        custom, 299–303                         date, time and number formats,
        Stroke interface, 283                          148–151
        styles, creating with BasicStroke,      language and country codes for,
            281–283                                    141, 151
LineStyles.java, 282                            menu pane, localized (example),
lineto( ), 206                                         153–156
Linkable interface, 33                          messages (user-visible), localizing,
LinkableInteger class, 34                              151–156
LinkedList class, 33                            resource bundles for, 151–156
LinkedList.java, 34                          localization, 141
linkTo( ), 411                               LocalizedError.java, 157–159
List component, 55                           LocateRegistry class, 395
listAllThreads( ) (ThreadLister), 73         locks
listDirectory( ), 55                            deadlock in threads, 75–77
Listener class, 102                             exclusive locks, thread synchro-
listeners                                              nization, 75
    for actions, Command objects as,         login screen with JSP, 471–476
            221                              login.jsp example, 471
    anonymous inner classes, defining         Logout.java servlet, 483
            with, 206–208                    log( ), 464
    drag-and-drop data transfer, 347         long data type, 14
    event, 182                               look-and-feel, GUI components, 184
        AnswerListener class, 360, 365          AppletMenuBar example, 257–263
        customizing, 211–217                    hardcoding layout, problems with,
        EventListener class, 203                       198
        mouse events, 204                       Metal, themes and, 253–257
        not using, 210                          Motif, 189
        registering and removing,               WebBrowser example, 235
            368–371                          LookupAPI.java, 446–450
    HttpSessionBindingListener inter-        lookup( ) (Naming), 397, 420
            face, 481                        loops, 3
listening                                       for, 8
    for datagrams, 117                          infinite, 91
    for client requests, 91                     loop counter, 8
ListResourceBundle class, 151                   while, 11, 60
lists                                        lostOwnership( ) (ClipboardOwner),
    item, choosing from, 211–217                       335
    JList component, 208                     low-level event handling, 210
    linked lists, 33                            custom components, 257
    ListSelectionListener interface,
            implementing, 208                M
ListSelectionEvent class, 208
ListServlets1.java example, 495–498          MacOS, component look-and-feel, 184
ListServlets2.java example, 499–502          mailhosts, 87
loading                                      mailto protocol, 87
    dynamic, of classes, 356                   SendMail.java program, using, 87
    JDBC drivers, 432
    untrusted code, 123


552   Index
main( )                              metadata, database
  args array, passing to, 10            GetDBInfo program, 438–441
  components, 184                       result sets, 434
  Compress.Test class, 60            metaDown( ) (Event), 381
  defined, 4                          Metal look-and-feel, 184
  FileCopy class, 50                    themes and, 253–257
  FileLister class, 56                  WebBrowser example, use in, 235
  FileViewer class, 53               MetalLookAndFeel class, 253
  GrepReader.Test class, 64          MetalTheme class, 253
  ListServlets1.java example, 496    Method class, 161
  Randomizer.Test class, 31          methods, 24
  RemoteBankServer class, 400           accessor, 28
  RemoveHTMLReader class, 62            argument names, Reflection API
  Server class, 102                             and, 161
  Thread class, 71                      bean, 355
  ThreadLister class, 73                blocks of code, 4
  TreeWalker class, 508                 instance, 24
  WebAppConfig example, 503                  static methods vs., 29
MakeAPIDB.java, 441–446                 interfaces, implementation by
makewar.sh example, 491                         classes, 24
MalformedResourceException (custom      invoking named, 164–168
          class), 243                   Locale-sensitive in Java, 142
manifest files, 359                      recursion of, 14
Manifest.java, 129–135                  signature of, 10
  functions of, 128                     static, 4
mapping servlet names to implemen-      synchronized, RemoteBankServer,
          tation classes, 460                   400
MAYSCRIPT attribute, 66                 visibility levels, 24
menubar, displaying in applet,       Microsoft
          257–263                       Internet Explorer, 65
menus                                   Windows (see Windows operating
  JMenuBar component in Scrib-                  systems)
          blePane application, 217   MIME type, 334
  localized menu panes, 153–156      minimumLayoutSize( ), 200
  MenuComponent class, 181           MissingResourceException, 153, 243
  parsing, 250–253                   mkdir( ) (File), 48
      MenuBarParser.java example,    modifiers, keyboard, 381
          251                        money
      MenuParser.java example, 252      formatting amounts for locales, 148
  pulldown, creating and configur-       FunnyMoney class, 397
          ing, 184                   Motif widgets, 181
  for themes, 254                    mouse events, handling, 204–208, 210,
message digests, 128–139                        257
  computing and verifying, 129          custom components, 257
MessageDigest class, 129                keyboard modifier constants, iden-
MessageFormat class, 156                        tifying, 381
messages                                MouseListener and MouseMotion-
  formatted, 156–159                            Listener interfaces, 204
  localizing for users, 151–156         ScribblePane1.java example, 205




                                                               Index   553
mouse events, handling (cont’d)          nesting
  ScribblePane2.java example,               components within other compo-
          206–208                                  nents, 183
mouseDown( ), 376                           containers within other containers,
mouseDragged( ), 205                               182
MouseListener and MouseMotionLis-           for loops, 11
          tener interfaces, 204             if/else statements, 9
mousePressed( ), 388                        windows in AWT components, 208
moveto( ), 206                           Netscape Navigator
MUD (multiuser domain), 404                 HTMLWriter program, running, 65
  client, MudClient.java, 420–427           Java 1.0 event model, support for,
  MudPerson class, 404, 418                        380
  MudPlace class, 404, 411–418           networking, 84–120
  remote interfaces, 405–408                with applets, 96–98
       Mud.java example, 405–408                Who.java example, 97
  server, 408–411                           client, generic, 99–101
       MUDServer.java example,              connecting to web servers, 89
          408–411                           downloading URL contents, 84
multiline message box, 369                  email, sending through URLCon-
MultiLineLabel.java, 356–359                       nection, 87
multipage text documents, printing,         GetURLInfo.java, 86
          319–327                           line terminator characters, 87
  HardcopyWriter example, 319–327           protocols, handlers for, 85
multiply( ), 17                             receiving datagrams, 117
  ComplexNumber class, 29                   RMI (remote method invocation)
multithreaded programming, 75                      (see RMI)
  AWT and Swing components,                 sending datagrams, 116
          thread-safety problems, 204       servers, 91
  deadlock in, 75                               multithreaded, generic, 101–113
multithreaded proxy server, 113–116             multithreaded proxy, 113–116
multiuser domain (see MUD)                      proxy, 93–96
MySQL database, 431                         URL connection, using, 86
  transaction support, versions lack-    new operator, 15, 24, 26
          ing, 451                       newlines, 87
  URL for, 432                              translating to local operating sys-
                                                   tem, 99
N                                        next( )
                                            ResultSet interface, 433
\n (newline) character, 87                  SpiralIterator class, 296
   translating to local operating sys-   no-argument constructors, 356
          tem terminator, 99                PropertyEditor interface, 368
named methods, invoking, 164–168         nodes
names                                       NodeFilter class, 508
   classes, 16                              specifying with DOM 2 tree, 508
   classes and packages, 6               notification events, 355
   servlets, mapping to implementa-      notify( )
          tion classes, 460                 Object class, 70
Naming class, 396                           Timer class, 77
                                         null filters, 62




554   Index
NullLayoutPane.java, 199                      pluggable look-and-feel, compo-
NumberFormat class, 148–149, 157                     nents, 184
numbers                                    org.w3c.dom package, 502
  complex, 28                              org.w3c.dom.traversal package, 508
  converting to strings, 157               org.xml.sax package, 495
  Fibonacci series, 10                     output streams (see output under
  prime numbers, computing, 22                       streams)
  random, 30–32                            OutputStream class, 47
  sorting, 21                              OutputStreamWriter class, 47, 141
                                              byte-to-char and char-to-byte con-
O                                                    verters, 146
                                           output( ), 503
OBJECT attribute (<APPLET>), 177           ownership, clipboard, 335
Object class, 24, 70
object serialization, 169–178              P
    applets, 177
    class versioning and, 176              packages
        advanced versioning, 177              declaring, 4, 6
    custom, 172–174                           importing, 16
        IntList.java example, 173          packets, UDP, 116
    data transfer and, 335                 @page directive, 471, 476
    deserialization, 170                   Pageable interface, 327
        transient fields and, 172           pages, getting number and format
    externalizable classes, 174–176                   (multipage document), 327
    MudServer class, 408, 411              pagination, multipage text documents,
    Serializable interface and, 169                   319
    simple, 169–172                           PrintableDocument class, problems
        Serializer.java example, 170–172              with, 327
    transient fields, excluding, 172           (see also HardcopyWriter.java;
ObjectInputStream class, 45, 169, 172                 PrintableDocument.java)
ObjectOutputStream class, 47, 169,         paint application (Scribble), 217–221
           172                             Paint interface, 276
objects, 24                                paintComponent( ), 267, 316
    Object class, 24, 70                   PaintContext class, 303
    remote (see remote objects)            painting
    (see also object serialization)           custom Paint (GenericPaint exam-
ObjectStreamClass class, 176                          ple), 303–305
obtaining examples online, xiv                filling shapes with Paint, 284–287
off-screen drawing                                Paints.java example, 285–287
    BufferedImage, creating with, 285      Paints.java, 285–287
    CompositeEffects example, 289             GradientPaint class, 285
    double buffering technique, 305           TexturePaint class, 285
openAccount( ), 451                        paintValue( ), 368, 370
open-source databases, 431                 paint( ), 267
open-source servlet containers, 459           applets and, 376
openStream( ), 85                             FirstApplet example, 377
operating systems                             ScribblePrinter1 (example), 314
    AWT components, implementing           panels
           on, 181                            JPanel class, 182
    line terminators, differences in, 87



                                                                     Index   555
panels (cont’d)                             PipedReader class, 46
   Panel class, 375                         PipedWriter class, 47
<PARAM> tag, 65, 377                        platforms, limitations in Unicode sup-
   setting parameter values with, 386                 port, 142
parameters                                  play( ) (AudioClip), 388
   applets, reading, 385–386                pluggable look-and-feel architecture,
   initialization, for servlets, 463, 488             Swing components, 184
   looking up image and audio click,        Policy class, 123
           applets, 387                     policy, security
   requests, servlets, 463                     creating and editing policy files,
parse trees                                           123
   DOM, traversing, 506–508                    Policy file, 122
   SAX 1 and, 494                              for SafeServer class, 124
   for XML documents, defining with             for servers, 122
           DOM, 502                         policytool program, 123
parse( ) (Command), 164, 221                portability, XML, 494
parseInt( ) (Integer), 17                   PortableRemoteObject class, 429
parsing                                     portal.jsp servlet, 477–481
   hot spot descriptions, 388               Portfolio.java, 149
   menus, 250–253                           ports, 89
       MenuBarParser.java example,             listening for datagrams on, 117
           251                              positioning constraints, GridBagLay-
       MenuParser.java example, 252                   out, 196
   ResourceParser class, 235, 243           positions, hardcoding for components,
       commands and actions, 248                      198
   ResourceParser.java example, 248         Post Office Protocol (POP), 99
   resources, ThemeManager exam-            POST requests, HTTP, 461
           ple, 254                         PostgreSQL database, 431
   toolbars, ToolbarParser, 251                URL for, 433
   URL content, 84                          preferred sizes
   XML                                         components
       with DOM Level 2, 508–512                   BorderLayout and, 193
       with JAXP and DOM, 502–505                  recomputing when deserialized,
       with JAXP and SAX1, 494–499                    173
       with SAX 2, 499–502                     containers, reporting for, 198
password verification, 471                      preferredLayoutSize( ), 200
paste( ), 344                                  preferredSize( ), 199
pasting, data transfer, 335                 prepared statements
PathIterator interface, 296, 300               creating, 442
Permission class, 122–123                      PreparedStatement class, 441
persistence                                 prepareStatement( ) (Connection), 442
   beans, 481                               previous( ) (ResultSet), 433
   data storage, 401                        prime numbers, 22
   remote references, 428                   Printable interface, 327
   servlets                                 PrintableDocument.java, 327–333
       across client requests, 458          PrinterJob class, 316
       Counter servlet example,             PrintFile class, 319
           463–467                          printing, 314–333, 434
PipedInputStream class, 45
PipedOutputStream class, 47


556   Index
printing (cont’d)                            resources, extension mechanism
   Graphics object, obtaining for                for, 248
            printer, 314                 look-and-feel vs. application values
   Java 1.1 API, 314–316                         for, 254
       multipage text documents          Properties files, 242
            (HardcopyWriter.java),           APIDB.java example, 442, 446
            319–327                          BankDB.props, 451
       ScriblePrinter1 example,          PropertyChangeEvent class, 368,
            314–316                              371
   Java 1.2 API, 316–319              property editors
       ScribblePrinter2 example,         AlignmentEditor example, 369
            316–319                      complex, 369
   PrintableDocument class, Web-         event listeners, registering and
            Browser example, 235                 removing, 368
   PrintStream class, 49                 initializing variable to current prop-
   Swing documents (PrintableDocu-               erty value, 368
            ment example), 327–333       PropertyEditor interface, 356, 366,
print( ), 7, 87                                  367
   applets and, 376                      registering, 367
printIn( ), 87                           simple, defining, 367–369
   Query servlet, 471                 PropertyChangeEvent class, 368, 371
println( ), 5                         PropertyEditor interface, 356, 367
printResultsTable( ), 434                methods for displaying and editing
printScribble( ), 314                            property values, 367
PrintStream class, 47                 PropertyEditorSupport class, 368
PrintWriter class, 47                 PropertyResourceBundle class, 151
private                               PropertyTable.java, 227–230
   fields, 28                          protected visibility, 24
   visibility, 24                     protocol handlers, 85, 87
processing images, 292–295            Proxy class, 113
   ImageOps.java example, 293–295     proxy servers, 93–96
processKeyEvent( ) (Component), 210      multithreaded, 113–116
processMouseEvent( ) (Component),     ProxyServer.java, 113–116
            210                       public, 4
processMouseMotionEvent( ) (Compo-       visibility, 24
            nent), 210                public key cryptography, 128
properties                            pulldown menus (see menus)
   bean, 355                          PushbackInputStream class, 45
       bound, 355                     PushbackReader class, 46
       constrained, 355               putFields( ) (ObjectOutputStream), 177
       indexed, 355
       listing, 366                   Q
   color, defining, 206                queries, SQL, 431, 434, 446
   displaying in tables, 227–230         RemoteDBBankServer, use of, 451
   GUI components, 183                Query.java servlet, 467–471
   GUIs, describing with, 242–253     queueing events, 204
       handling basic resources,      quit button, adding to button box con-
            243–248                             tainer, 182
       parsing commands, 248
       parsing menus, 250–253


                                                                  Index    557
R                                            property editors, 367
                                             PropertyChangeListener objects,
random numbers                                       370
   pseudo, 30–32                          Registry interface, 395
   Randomizer class, 30                   registry service
   Randomizer program, 31                    registering remote object with, 395
   seed, 30                                  registry server, running, 396
RandomAccessFile class, 44                relative( ) (ResultSet), 433
Reader class, 46, 62                      remote interfaces, 395
read( ), 62                                  MUD, 405–408
readExternal( ) (Externalizable), 174            Mud.java example, 405–408
readFields( ) (ObjectInputStream), 177    remote method invocation (see RMI)
readLine( ), 18                           remote objects, 395
readObject( ), 172                           activation, 428
   ObjectInputStream class, 169–170       RemoteBank interface, 396, 400, 450
real numbers, 28                             persistent data storage in, 401
real( ), 28                               RemoteBankServer.java, 400–403
rebind( ) (Naming), 400                      RemoteBankServer class, 450
receive( ) (DatagramSocket), 117          RemoteDBBankServer.java, 451–456
receiving datagrams, DatagramSocket,      RemoteException, 395–396
           116                            RemoteMudPerson interface, 405, 418
Rect class, 25                            RemoteMudPlace interface, 405, 411,
   subclasses of, 27                                 420
   testing, 26                            RemoteMudServer interface, 405, 420
Rect.java, 25                             RemoveHTMLReader.java, 62
Rect( ), 26                               removePropertyChangeListener( ), 368
recursion, 14                             removing
   in object serialization/deserializa-      event listeners, 368
           tion, 169                         property change event listeners,
red, green and blue components,                      371
           specifying for colors, 272     renameTo( ) (File), 48
references to remote objects              RenderingHints class, 276
   client, obtaining with Naming class,   RequestDispatcher class, 476
           396                            requests, HTTP, 461
   persistence of, 428                       forwarding, 476
reflection, 161–168, 356                   reshape( ), 198
   actions and, 221                       resource bundles
   class and member information,             GUIResourceBundle class, 235
           obtaining, 161–164                localized menu panes (example),
   GUIs, use with, 184                               153–156
   named methods, invoking, 164–168          ResourceBundle class, 141, 151–153
   Reflection API, 161                            in GUI descriptions, 242
Regional Settings control (Windows        resources
           Control Panel), 151               extension mechanism for complex,
registerEditor( ) (PropertyManager),                 248
           367                               parsing, ThemeManager example,
registering                                          254
   bean customizer, 371                      ResourceParser class, 235, 243
   event listeners, 368                      ResourceParser.java, 248
   JDBC drivers, 432



558   Index
responses, HTTP, 482                    run( )
ResultSet interface, 432–433               Runnable interface, 70
    scrollable, configuring, 433            Thread class, 378
ResultSetMetaData class, 434               TimerTask, 77
Reverse program, 11
RMI (remote method invocation),         S
            395–430
    advanced, 428                       SafeServer class
        activation, 428                     policy file, 124
        CORBA interoperability with         testing security of services, 125–128
            RMI/IIOP, 429               SAX (Simple API for XML), 494
        remote class loading, 428           HandlerBase class, 496
    applications, developing, 395           SAX1
    bank server, 400–403                        JAXP support for, 495
        RemoteBankServer.java exam-             parsing with, 494–499
            ple, 401–403                    SAX2, parsing with, 499–502
    compiler (see rmic)                 scratch fields, object serialization and,
    MUD (multiuser domain), 404                    172
        client, 420–427                 ScribbleCutAndPaste.java, 344–347
        MudPerson class, 418            ScribbleDragAndDrop.java, 347–353
        MudPlace class, 411–418         Scribble.java, 217–221, 338–343, 381
        remote interfaces, 405–408      ScribblePane1.java, 205
        server, 408–411                 ScribblePane2.java, 206–208
    remote banking, 396–400             ScribblePane3.java, 208
        Bank.java example, 397–400      ScribblePane4.java, 210
rmic compiler, 396, 400                 ScribblePrinter1.java, 314–316
    RemoteDBBankServer, running for,    ScribblePrinter2.java, 316–319
            451                         scriptlets
rmid program, 428                           scriptlet tags, 472
rmiregistry, 396                            surrounding HTML tags with, 478
    RemoteDBBankServer, starting for,   scrollable result sets, 433
            451                         SecretKey class, 136
    rmid performing function of, 428    SecureService.java, 125
rollback( ), 450–451                    security, 121–140
RootPaneContainer class, 223                access control, 121
rot13 substitution cipher, 19               applet restrictions, 375
Rot13Input.java, 19                         authentication, 121
Runnable interface, 378                     cryptography, 136–139
running                                     finger program, concerns about, 96
    Counter servlet, 467                    manifest file for digital signatures
    Hello servlet, 462                             and message digests,
    ListServlets1.java, 498                        129–135
    ListServlets2.java, 502                 message digests and digital signa-
    programs, 5                                    tures, 128–139
    Query servlet, 471                      policy
    SafeServer class, 127                       default from Sun Microsystems,
    servlets, 460                                  122
    WebAppConfig example, 505                    for SafeServer class, 124
    WebAppConfig2 example, 514               SafeServer class, testing, 125–128




                                                                    Index    559
security (cont’d)                          services
    SecurityManager class, 122                classes, downloading from URL,
<select> tag, 478                                     123
selection dialogs                             classes for, dynamically loading,
    FontChooser example, 222–227                      101
    JColorChooser and JFileChooser,           ConnectionManager class and, 102
           222                                Control class, 102
    JColorChooser, displaying, 217            Service interface, 102
selection events, tree node, 230              specifying directories for loading
SendMail.java, 87                                     and writing to temporary
send( ) (DatagramSocket), 116                         files, 124
sentence boundaries, locale-depen-         <servlet> tag, 467, 488, 495
           dent, 148                       <servlet-mapping> tag, 488
SequenceInputStream class, 45              <servlet-name> tags, 503
.ser file extension, 178                    servlets, 458–493
Serializable interface, 169                   compiling, 460
serialization (see object serialization)      containers, 459
Serializer.java, 170–172                          session tracking, 482
serialver command, 177                        Counter servlet, 463–467
Server class                                  database access with, 467–471
    running under security manager,           Hello world, 461–463
           122                                    running, 462
    Service interface and, 102                HttpServlet class, 458
Server.java, 102–113                          installing and running, 460
servers, 396                                  JSP and (login screen example),
    connecting to, 89                                 471–476
    database, 431                             Query, running, 471
       connecting to, 433                     Servlet 2.2 specification
       servlets communicating with,               JSP 1.1 specifications and, 459
           467                                    web.xml file, format and con-
    MUDServer.java example, 408–411                   tents, 488
    multithreaded, generic, 101–113           Servlet interface, 458
    proxy, 93–96                              setup, 458
       multithreaded, 113–116              <session-config> tag, 488
    RemoteBankDBBankServer exam-           sessions, user
           ple, 451–456                       ending, 482
    RemoteBankServer.java, 400–403            mangement information, 488
    RMI, 395                                  servlet container tracking of, 461
    security policy for, 122                  UserBean, removing from, 481
    Server class, 101                      setAsText( ), 368
    ServerSocket class, 84, 91             setAutoCommit( ), 451
    Service interface, 101                 setBounds( ), 198–199
    simple, 91                             setColor( ), 206
    single-threaded, 91                    setComposite( ) (Graphics2D), 289
server-side includes (SSI) 467             setConstraints( ) (GridBagLayout), 196
ServerSocket class, 84                     setContents( ), 335
server.xml file (Tomcat), 514               setCurrentTheme( ) (MetalLookAnd-
Service interface, 113                                Feel), 253
                                           setDefault( ) (Locale), 142




560   Index
setDoInput( ), 87                         SimpleProxyServer.java, 94–96
setDoOutput( ), 87                        single-threaded servers, 91
setFile( ), 52                                proxy, 93–96
setLayout( ), 190                         sizes, 198
setObject( ), 371                             hardcoding for components, 198
setPage( ), 234                               (see also preferred sizes)
setReadOnly( ) (Connection), 446          skeletons (see stubs and skeletons)
setRenderingHint( ) (Graphics2D), 277     slashes, JAR manifest filenames, 360
setStroke( ) (Graphics2D), 277            sleep( ) (Thread), 71
setter and getter methods, 183            SloppyStroke class, 300
setText( ), 234                           sockets
setTheme( ), 254                              DatagramSocket class, 116
setup, servlets, 458                          ServerSocket class, 84, 91
setUserName( ), 481                           Socket class, 84, 89
setValue( ), 368                          sorting
shadowing, creating with translucent          numbers, SortNumbers.java, 21
           colors, 285                        Sorter.java example, 37
Shape interface, 276, 295                     strings, with Collator object, 148
    custom, Scribble example, 338         Soundmap.java, 388–391
shapes                                        JAR files, 391
    customizing, 295–299                  sounds
        Spiral.java example, 296–299          and images in applets, 387–391
    displaying in GraphicsExample-                loading sound file, 388
           Frame, 277                         loading network sound clip, 376
    drawing and filling, 277–279           source code, downloading for exam-
        antialiasing and, 287                        ples, 7
        Shapes.java example, 278          space, device vs. user, 276
    filling with Paint, 284–287            Spiral.java, 296–299
        GenericPaint example, 303–305     SQL (Structured Query Language),
        Paints.java example, 285–287                 431–457
    transforming, 279–281                     accessing a database, 432–438
shell commands, setting CLASSPATH             database metadata, using, 438–441
           environment variable with, 7       databases
shiftDown( ) (Event), 381                         atomic transactions, 450–456
show( ), 52                                       building, 441–446
    FontChooser class (example), 223              using, 446–450
ShowClass.java, 161–164                       ExecuteSQL program, 433–438
ShowComponent.java, 183–188                   queries, 431, 446
    layout managers, demonstrating,               Query servlet example, 467–471
           191                                    RemoteDBBankServer, use of,
showDocument( ) (AppletContext),                     451
           377, 388                               sending, 433
showStatus( ), 377, 388                       SQLException, 432, 434
Sieve of Eratosthenes algorithm, 22           SQLWarning class, 434
Sieve.java, 22                            SSI (server-side includes), 467
Signature class, 129                      startElement( ) (HandlerBase), 496
signature, methods, 10                    start( ) (Applet), 178, 376, 378
SimpleBeanInfo class, 365                 Statement interface, 432–433
SimpleCutAndPaste.java, 335–338
SimpleMenu.java, 154–156


                                                                    Index   561
statements                                 StringBufferInputStream class (depre-
    nested, 9                                         cated), 45
    synchronized, RemoteBankServer,        StringReader class, 45–46
            400                            strings, 11
static (class) fields, 15, 24                   arrays of, 10
static methods, 4                              character streams, filtering, 62–64
    add( ) and multiply( ), Com-               comparisons, locale-dependent,
            plexNumber class, 29                      148
    instance methods vs., 24                   concatenating, 26
statistics, 32                                 converting numbers to, 157
status line message, displaying in             in data transfer, 334, 338
            browser or applet viewer,          editing, 368
            377                                String class, 18–19
stock portfolio, display following local       StringBuffer class, 19
            conventions, 149               StringSelection class, 338
stop( ) (Applet), 376, 378                 StringTokenizer class, 388
streams, 44–49                             StringWriter class, 47
    client-server network connections,     stroking, 276
            89                                 CustomStrokes.java example,
    file contents, working with, 49–51                 299–303
    files and directories, compressing,         line styles, creating with Basic-
            60–62                                     Stroke, 281–283
    input                                      Stroke interface, 276, 283, 299
        byte input streams, 45–46              Stroking.java example, 283
        character input streams, 46        Structured Query Language (see SQL)
        CheckedInputStream class, 45       struts, Box container layout, 194
        DataInputStream class, 169         stubs and skeletons, 396
        DigestInputStream class, 129           generating, 400
        GrepReader class, 64                   stubs, client remotely loading, 428
        InputStream class, 85              styles, lines
        InputStreamReader class, 49,           creating with BasicStroke, 281–283
            141                                    LineStyles.java example, 282
        ObjectInputStream class, 169       sub-blocks of code, 4
        PipedInputStream class, 45         subclasses, 24
        SequenceInputStream class, 45      superclasses, 24
        StringBufferInputStream class,     supportsCustomEditor( ), 368
            45                             Swing GUIs
        ZipInputStream class, 46               components, listing of, 183
    output                                     container classes, 189–190
        byte output streams, 46                custom components, 211–217
        character output streams, 47           displaying components, 183–188
        CheckedOutputStream class, 46          displaying tables, 227–230
        custom HTML, 65–68                     event listeners, defining, 204
        DataOutputStream class, 169            JavaBeans component model,
        ObjectOutputStream class, 169                 event-handling API, 203
        OutputStreamWriter class, 141,         layout management (see layout
            146                                       management, GUIs)
        PipedOutputStream class, 47            lightweight nature of components,
        PrintStream class, 49                         208




562   Index
Swing GUIs (cont’d)                           HTMLWriter class, 65
   locale property in components, 142         LinkedList class, 34
   mouse events, handling, 204–208            Randomizer class, 31
   pluggable look-and-feels, 184              SafeServer security, 125–128
   printing documents (PrintableDoc-       text
          ument example), 327–333             art, creating with, 285
   trees, displaying, 230–234                 centering, 267
SwingUtilities class, 254                     converting to/from locale-specific
switch statements, 12                                and Unicode, 141, 146–148
   syntax of, 13                              filtering lines of, 64
synchronization                               glyphs, antialiasing and, 288
   RemoteBankServer, 400                      javax.swing.text package, 327
   synchronized methods vs. synchro-          JTextComponent, 234
          nized statements, 75                plain, 91
   threads, problems with, 75–77              printing multipage documents,
synchronized code blocks, 464                        319–327
synchronized statement, 70                 text files, reading and displaying,
system properties, specifying for ser-               52–55
          vices, 124                       TextArea component, 52
SystemColor class, 273                     TextField component, 55
                                           TexturePaint class, 276, 285
T                                          ThemeManager.java, 253–257
                                              ThemeManager class, 253
tabbed panes (see JTabbedPane con-         themes
           tainer)                            for Metal look-and-feel, 253–257
TableModel interface, 227                     WebBrowser example, definition of
tables                                               available, 254
    displaying, 227–230                    Thread class, 70
        JTable class, 227                     ThreadGroup class, membership in,
        PropertyTable example, 227–230               72
tag library descriptor (TLD), 483          thread safety in AWT and Swing com-
@taglib directive, 476, 478                          ponents, 204
tags, JSP, 458, 471                        ThreadDemo.java, 71
    custom, 483–487                        ThreadGroup class, 72
        defining, 484–486                   ThreadLister.java, 73
        deploying, 486–487                 threads, 70–83
    interface to RequestDispatcher            in animation, 274
           class, 476                         applets and, 375
    library for JSP page, declaring, 472      daemon, 73
targets                                       deadlock in, 75–77
    for data drops, 347                       event dispatch thread, 204
    for events, 380                           hierarchy, 73
temporary fields, excluding from               multiple, executing doGet( ), 464
           object serialization, 172          multithreaded proxy server,
temporary file locations for services,                113–116
           specifying, 124                    multithreaded server, 101–113
test expression, in for statements, 8         thread groups and, 72–75
testing                                       using anonymous second, 99
    compressed files, 60                    throwing exceptions, 15, 19
    GrepReader class, 64



                                                                    Index   563
tile( ), 267                                 translucent colors, 276
tiling, images, 276                              in antialiased drawing, 288
time                                             drawing with, 289
    clock applet, 378–380                        Paints.java example, 285
    formatting for locales, 148–151          Tree class, 230
Timer class, 77, 204                         TreeModel interface, 230
    text-based animation, performing,        trees, displaying, 230–234
           234                               TreeWalker class, 508
timers, 77–82                                TripleDES encryption algorithm, 136
    java.util.Timer vs.                      TripleDES.java, 136–139
           javax.swing.Timer, 77             true values, returned by event-han-
    Timer.java, 78–82                                   dling methods, 381
    TimerTask.java, 77                       trusted code, 121
timestamps, 86                               try clauses, 18–19
TimeZone class, 148                          try/catch statements, 15, 17
TLD (tag library descriptor)
    creating for custom tag deploy-          U
           ment, 486–487
    mapping to URI of custom tag             UDP (Unreliable Datagram Protocol),
           library, 488                                116
    <uri> tag, 486                              DatagramPacket class, 116
Tomcat servlet container, 459                   UDPReceive.java, 118
    downloading and installing, 459             UDPSend.java, 116
    server.xml file, 514                      UIResource class, 254
    WAR file, 460                             unhandled events, passing up contain-
toolbars                                               ment hierarchy, 381
    JToolbar component, using with           UnicastRemoteObject class, 395
           scribble application, 217         Unicode, 141–146
    ToolBarParser class, 251                    some characters and their encod-
Toolkit class, 335                                     ings, 143
top-level windows, 189                          Standard, information about, 142
    (see also JFrame component)              UnicodeDisplay.java, 143–146
toString( ), 25                              Unix operating systems, 181
transactions, atomic, 450–456                Unreliable Datagram Protocol (see
transferable data type, 338–343                        UDP)
Transferable interface, 334                  untrusted applets
    in drag-and-drop transfer, 347              networking and, 96
    Scribble example, 338                       system clipboard and, 335
transferring data (see data transfer)        untrusted code
transformations, 276                            loading, 123
    AffineTransform class, 279, 285              running, 122
    shapes, 279–281                          update expression, in for statements, 8
transient fields                              updating databases, 434, 442
    MudPlace class, 411                         auto-commit mode, 450
    not including in object serialization,   <uri> tag, 486
           172                               URIs
translate( ) (Graphics2D), 277                  getRequestURI( ), 476
translating user-visible text to local          tag library, mapping to local TLD
           language, 141                               file copy, 483




564   Index
URLs                                     visibility
   base, for applet class file, 377           class fields and methods, 24
   database                                  private fields, 28
       MySQL, 432                            public, 4
       PosgreSQL, 433                    VM (Virtual Machine), 6
   destination URL, showing, 388             data transfer, problems with, 335
   downloading contents of, 84               servlets JAR file path for, 460
   for DTD, replacing with local copy
          name, 499                      W
   GetURL.java, 85
   HttpURLConnection class, 86           wait( )
   jdbc, specifying, 432                   Object class, 70
   JSP tags, 472                           Timer class, 77
   request parameters, servlets, 462     WAR archives, 460
   servlet instance, mapping to, 488       packaging web applications into,
   servlets, invoking through, 463                 490
   URL class, 84                         warnings, 434
       in WebBrowser program, 234        warning( ) (HandlerBase), 496
   url parameter, 66                     web applications, 460
   URLClassLoader class, 123               configuring with web.xml, 488–490
   URLConnection class, 84                 deploying, 488–491
       sending email through, 87           deployment descriptor
       using, 86                                parsing with DOM, 502–505
   WAR archives, 460                            parsing with ListServlets1 pro-
user input events, EventTester applet,             gram, 495–498
          383–385                          packaging into WAR files, 490
user sessions                            web browsers
   associating bean with, 477              applets and Java 1.0 event model,
   ending, 482                                     380
   mangement information, 488              simple, creating, 234–242
user space, transformations in, 276      web pages, including Counter output,
UserBean.java, 481                                 467
   UserBean class, 477, 481              web servers, 89
user.name system property, 87              Java Servlet API as extension for,
usernames, finding with Hello servlet,              458
          461                              open-source, Apache, 459
users (logged-on), displaying with fin-     SSI (server-side includes), 467
          ger, 96                          (see also servers)
                                         WebAppConfig2.java, 512
V                                          compiling and running, 514
                                         WebAppConfig.java, 502–505
valueBound( ), 481                         compiling and running, 505
variables, static fields vs., 15            XMLDocumentWriter class, 506
Vector class, 388                        WebBrowser.java, 234–242
versions, classes                          look-and-feel, 235
   advanced versioning, 177              web.xml file, 460, 488, 495
   object serialization and, 176           configuring web applications with,
viewing applets, 378                               488–490
                                           <!DOCTYPE> tags in, 498




                                                                    Index    565
web.xml file (cont’d)                       portability of, 494
   id attributes for tags, 496             SAX (Simple API for XML), 495
   <servlet-mapping> tag, 488              servlet.xml file, 514
   <session-config> tag, 488                web.xml file, 488
while loops, 11, 49, 60                    XMLDocumentWriter class, 503
Who.java, 97                             XMLDocumentWriter.java, 506–508
widgets, 181
windows                                  Y
   GraphicsExampleFrame program,
           277, 308–311                  YesNoPanelBeanInfo.java, 365–367
   JFrame class, 182                     YesNoPanelCustomizer.java, 372
Windows operating systems                YesNoPanel.java, 360–364
   controls, AWT components and,         YesNoPanelMessageEditor.java, 369
           181                           yield( ) (Thread), 71
   locales, setting on, 151
   look-and-feel, components, 184        Z
   manifest files, slashes in, 360
word boundaries, locale-dependent,       zipDirectory( ), 60
           148                           ZipEntry class, 60
World Wide Web Consortium (W3C),         ZipInputStream class, 46
           DOM standard, 502             ZipOutputStream class, 47, 60
write( )
   Writer class, 65
   XMLDocumentWriter class, 506
writeExternal( ) (Externalizable), 174
writeFields( ) (ObjectOutputStream),
           177
writeObject( ), 172
   ObjectOutputStream class, 169
Writer class, 48
   HardCopyWriter example, 319
writers, character output streams, 47
writing beans, 355

X
Xerces parsers, 499
   DOM Level 2, support for, 508
   Xerces-J, downloading, 502
XML, 494–515
   DOM tree, traversing, 506–508
   JAXP (Java API for XML Parsing),
         495
   JDOM (Java-centric XML API), 494,
         512
   parsing
      with DOM Level 2, 508–512
      with JAXP and DOM, 502–505
      with JAXP and SAX1, 494–499
      with SAX2, 499–502



566   Index