- Shopping Bag ( 0 items )
Ships from: fallbrook, CA
Usually ships in 1-2 business days
Java™ servlets are rapidly replacing CGI as the tool of choice for creating interactive applications for the enterprise market. Using the Java programming language's servlet technology speeds up the application development process, freeing developers from the need to make platform-specific modifications. Servlet technology is reliable, employs reusable components, and ensures high performance in the demanding enterprise and e-commerce markets.
Enterprise Java™ Servlets anticipates common issues and provides new development methods, extensive sample code, and case studies. The book is based on a battle-tested base servlet architecture that the author and his team created while repairing a workflow application for clients. Jeff noticed that many corporations and development shops ran into the same problems and pitfalls time and time again. This book chronicles Jeff's experiences creating a servlet-based architecture, which helps avoid issues that are continually encountered and provides for rapid application development in the enterprise. The type of architecture presented here eliminates the need to code servlets from scratch and automatically provides each servlet with access to all the new features and solutions added to the base servlet. This type of single-servlet approach results in a single, consistent application that is easy to migrate to production and extend to new applications.
You'll find expert coverage of various topics,including:
Geared to developers who have a working knowledge of servlet development, this book provides the base servlet architecture—complete with extensive code samples and numerous case studies—that you can build on when writing enterprise applications. Using base servlet architecture removes the drudgery of developing servlets, so you can concentrate on business needs.
The accompanying CD-ROM includes code examples, as well as Windows and UNIX versions of JRun, ServletExec, and Apache Tomcat Servlet Container.
An enterprise application is a system that is considered mission critical with little tolerance of downtime. The word enterprise has a very broad meaning in business, but it has one single foundation: reliability. So what are enterprise servlets? They are a method and a framework for developing Java servlet applications that allow the developer to create enterprise-level Web-based applications.
Any of us who are corporate developers will encounter the various situations that are presented in this book at one time or another when working on servlet applications. Some of the topics covered here include the following:
Because this book covers advanced topics in servlet development, it is geared toward developers who have a basic understanding of servlet development. The reader should be familiar with creating a servlet and using some of the associated objects (such as
HttpSession), and with JavaServer Pages (JSP).
In the development of a servlet application, a servlet container is typically used—preferably one that is written in Java so that the servlet may be "stepped" through during debugging. A servlet container is nothing more than a simplified servlet engine. There are a few types of servlet containers on the market, some with more options than others. Two such containers are Tomcat and the ServletExec debugger by New Atlanta; the first is free, the second, commercial.
Tomcat is managed by the Apache project. Although the name Apache may make you feel as though you must use the Apache Web server, this is not true. Tomcat is just a Java application that acts as a container for Java servlets, and it comes with plug-ins to allow it to run with Apache, Internet Information Services (IIS), and iPlanet. Because it is a Java application, it is not only a great production-level servlet container, but can also be used to debug servlets in an integrated development environment (IDE). In fact, versions of Borland's JBuilder 4 include Tomcat as part of its servlet development platform for debugging servlet applications.
The ServletExec debugger can be purchased with the ServletExec servlet engine, which allows the developer to debug in an environment that appears like the production engine but run it in an IDE for debugging. The nice thing about this product is that no configuration files need to be edited directly. The entire servlet control interface is done through HTML and a Web browser. This really helps when you're setting up a servlet application.
Pure Java application servers, such as WebLogic, can also be used for debugging servlets. However, the downside of using application servers for development and debugging is that they usually consume a very large amount of memory and take a long time to launch. These requirements could slow down the software development cycle and require more memory to be installed on workstations, but debugging can be done successfully with application servers.
This is one way to run servlets and install them as part of an application. However, running servlets in this way could potentially pose a security risk. In addition, it gives away too much information about the application, and it does not give us much control over how we execute servlets. For example, taking this approach might mean that we cannot have the servlets initialize automatically when we start the Web server or set other parameters that tell us how the servlet should execute. In addition, this approach tells the end user the structure of the application, as well as what technology is being used. It is not too difficult to figure out the package structure when servlets are run in this way. This is usually a lot more information than end users need to know. Minimizing the information that users receive about how an application executes dramatically lowers the chances of a security breach....
|Chapter 1||Introduction to Enterprise Servlets||1|
|Developing Servlets and Servlet Containers||2|
|Setting Up and Running Servlets||3|
|Registering Servlets with the Servlet Container||4|
|What You Need||6|
|The Base Enterprise Servlet||7|
|The Single-Servlet Approach||14|
|Base Enterprise Servlet Basics||14|
|Implementation of a Base Servlet||18|
|The Class.forName() Method||24|
|The Http Method Class||31|
|The ConfFile Class||32|
|The MethodList Class||34|
|Chapter 2||AppContext: Managing Applications||39|
|The Configuration File Revisited||41|
|The AppContext Object||42|
|A Two-Application Example||56|
|Forcing Uniqueness across Applications: AppManager||63|
|Chapter 3||Forms, State, and Session Management||71|
|HTTP Forms: A Review||72|
|The [left angle bracket]FORM[right angle bracket] Tag||72|
|Packaging the Query with GET and POST||75|
|HTTP Forms and Enterprise Servlets||77|
|Form and HTML Development in the Enterprise||79|
|Maintaining State with Sessions in the Enterprise||86|
|Standard Servlet Architecture and Sessions||90|
|The Enterprise Session||93|
|Session and Form Example with Multiple Applications||103|
|Chapter 4||HTML with Templates||117|
|JSP as a Template Engine||119|
|Developing a Template Engine||120|
|The HTMLTemplate Object||126|
|Templates with Enterprise Servlets||134|
|Making the Template Engine Scream: Caching Templates||143|
|Building the Template Cache||146|
|Integrating the Template Objects and Cache into Enterprise Servlets||157|
|Using the Template Cache in Enterprise Servlets||163|
|Chapter 5||Logging and Error Handling||169|
|Logging in a Servlet Engine||169|
|Anomalies of a Servlet Engine Log File||171|
|Components of a Standardized Log File||172|
|The EnterpriseLog Object||175|
|Logging in Enterprise Servlets||188|
|A Logging Example||195|
|The DefaultErrorHandler Object||204|
|The Logger Application with Error Handling||208|
|Types of Security||213|
|Under the Hood||218|
|Customizing Web Authentication||220|
|An Example Using Pluggable Security Components||223|
|Integrating Form-Based Authentication into Enterprise Servlets||230|
|What Is a Pool?||240|
|Using Pools in Web Development||242|
|The Base Pool Object||244|
|Using the Pool Object||253|
|Using the Pool: An Example||255|
|The Pool Anomaly||259|
|PoolList and PoolObjectManager||262|
|Using PoolList and PoolObjectManager: An Example||269|
|Chapter 8||Database Connectivity||273|
|JDBC: a Quick Review||273|
|Loading the Driver and Connecting to the Database||274|
|The JDBC Statement and Result Set Objects||275|
|The PreparedStatement and CallableStatement Objects||276|
|Closing the Connection||278|
|Managing the Connection in a Server Environment||278|
|Understanding Connection Management||281|
|Building Connection Management||284|
|The JDBCManager Object||284|
|The SQLCursor Object||287|
|The DBConnection Object||293|
|Using the Connection Management Objects||294|
|Database Pooling with the Connection Management Objects||297|
|Using the DBConnectionPool Object||300|
|Making the DBConnectionPool Object Easier to Create||304|
|The Name ValuePair Object||306|
|The DBPoolParser Object||307|
|Using DBPoolParser in Enterprise Servlets||313|
|Chapter 9||LDAP Connectivity||317|
|A Little History of LDAP||318|
|How LDAP Works||318|
|Advantages and Disadvantages of LDAP||320|
|LDAP with Java: The JNDI||321|
|Connecting to LDAP||321|
|Searching LDAP for Values||322|
|Adding and Removing an Entry||325|
|Modifying Attributes within an Entry||327|
|Closing the LdapContext Object||327|
|LDAP Considerations in a Server Application||327|
|Building the LDAP Connection Management Objects||329|
|The LDAPManager Object||330|
|The LDAPConnection Object||337|
|Using the LDAP Connection Management Objects||338|
|The LDAPConnectionPool Object||340|
|Putting the Connection Management Objects to Use||343|
|Chapter 10||Dynamic Graphics||351|
|How a Browser Requests Images||352|
|Handling Image Types||354|
|Creating Objects Is Your Worst Enemy||361|
|Pooling Memory Buffers||361|
|Random Pie Chart Example||364|
|Chapter 11||Using JSP with Enterprise Servlets||375|
|Is There a Preference?||375|
|JSPs with Servlets||376|
|JSPs and Enterprise Servlets||384|
|Releasing BaseEnterpriseServlet's Grip on AppContext||385|
|Tapping into Enterprise Servlets||388|
|A Quick Look at the Java Tag Library||389|
|Bridging JSPs to Enterprise Servlets||395|
|Using the ESBridge Tag Library||404|
|Accessing the EnterpriseSession Object||408|
|Using the [left angle bracket]ESSession[right angle bracket] Tag||413|
|Chapter 12||Taking Enterprise Servlets Further||419|
|Web Server Startup in a Multiapplication Environment||419|
|Enhancements for the Reader||428|
|The Template Engine||428|
|Database and LDAP Pools||428|
|An Administrative Tool||429|
|A Pager or E-Mail Monitor||429|
|Anything You Want||429|
If you are only beginning to work with Java servlets, consider purchasing Inside Servlets: Server-Side Programming for the Java Platform, Second Edition (2001), by Dustin R. Callaway, and/or Java Servlet Programming, Second Edition (2001) by Jason Hunter, with William Crawford. Inside Servlets is an excellent book about Java servlets and is a good companion for this book. Callaway's book is easy to read, flows well, has basic and advanced sections, and gives an excellent introduction to servlets, teaching you all you need to know to write Java servlet applications. Java Servlet Programming covers a broad range of Java servlet topics.
Although it did not seem that way at the time, it was while working for one of my clients that I happened on a most fortunate set of circumstances. In mid-1999, my team of developers inherited a servlet-based Web application from a previous team. The application was a workflow application to automate travel requests and authorizations that had been slammed together in a short period of time and then "thrown over the wall" to the company. The application's documentation was sparse, the code's database was a mess, the functionality was just basic at best, and the structure and flow were barely functional and nonscalable.
To clean it up, my team worked on the application for a considerable period of time, nearly double the time it took the original developers to code it. It was during this process that I began to more fully understand servlet architecture, including the best way to code applications so that it is possible to add functionality more quickly, to make scalability and reliability more certain, and to ensure that future maintenance of code is simpler. After revamping the entire application, my team suddenly realized what we had--the basis for a framework and architecture that others could use to create robust, scalable, extensible, well-documented servlets.
We gave ourselves a target of three weeks--three weeks in which to create an entire expense-reporting application. But instead of diving right into the code, we sat down and planned out a base-servlet architecture, something we could use to create this application, as well as subsequently. We wanted to have something on which to build future applications, all the while improving the base from which we worked.
We came up with a base servlet from which all servlets would be created. So as not to make the same mistakes the consulting company had made, we were always mindful of what we learned while cleaning up the travel application. We wanted to be sure that we would need to code the application only once, and that we could easily add more functionality, as needed, later. The end product was completed in just over a week, and the expense application was completed a week and a half later, just as quickly as an ASP team could have done the work. The application was stable, reliable, and extensible, and it formed a framework for all future projects.
It was at that moment that I started to talk about writing this book, to pass on what we had learned. As my team talked with other developers and mentioned what we had built, invariably they asked for the code. The architecture provided so much functionality right out of the box that it didn't make sense to code servlets from scratch anymore. As we continued to develop applications on top of the base servlet and to augment it with many other useful enterprise-scale enhancements, my interest in writing the book grew.
In the intervening months before this book was done, my team didn't rest on its laurels. We pressed on and built a servlet architecture that surely will be valuable for every corporate Java developer. This is not the right way to build servlets, merely a right way. While other servlet architectures may work well (a select few may even work better), the ideas in this book certainly will improve any architecture. My hope is simply that I can pass on what my team learned so that your applications will be better, faster, more reliable, and easier to code and maintain.
Enterprise Java™ Servlets is not intended to compete with any other Java-based technology, such as Enterprise JavaBeans (EJBs) and/or JavaServer Pages (JSPs), but to complement them. Because many JSP-based applications delegate the more intensive processing to servlets, the techniques here can be applied and used in this environment. In addition, EJBs are now used to facilitate many aspects of server-side processing. In our world of e-commerce applications, however, we still use servlets as the interface to the Enterprise JavaBeans; thus many of the techniques in this book will be useful. Because servlets are the center of Java-based server technologies, either through the compilation or delegation of a JSP page or as an interface to EJBs, this book shows some effective and efficient techniques for developing servlets in an enterprise environment.
There are many excellent books about JSPs and EJBs, so I do not need to describe how we use these technologies with servlets; other books do a fine job of that. Instead, this book discusses the problems and issues that developers will run into when developing servlets, as well as development methods that can be implemented to streamline how servlets execute. This by no means prevents one from using these techniques when developing servlets with JSPs or EJBs, and I hope you will find them useful when you are writing enterprise applications.
Posted November 20, 2001
The book is a great 'tricks and traps' of servlet development. Shows all kinds of techniques for writing servlets. I highly recommend it for developers who need to understand some of the intricacies of servlet development. Its required reading for my team.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted November 19, 2001
Just putting the word 'Enterprise' on a book cover doesn't make this an 'Enterprise-ready' book. The author fails to learn from the lessons of true Enterprise systems (COBOL, for example) where UI and data elements became tightly bound. Those who fail to capitalize on declarative user interface models are bound to repeat these mistakes. And the author is furthering the foundation required to repeat these mistakes in Java.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.