Java Servlet & JSP Cookbook and over 2 million other books are available for Amazon Kindle . Learn more

Sign in to turn on 1-Click ordering.
Trade in Yours
For a 1.58 Gift Card
Trade in
More Buying Choices
Have one to sell? Sell yours here
Sorry, this item is not available in
Image not available for
Image not available

Start reading Java Servlet & JSP Cookbook on your Kindle in under a minute.

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.

Java Servlet & JSP Cookbook [Paperback]

Bruce W. Perry
3.5 out of 5 stars  See all reviews (2 customer reviews)
Price: 32.50 & FREE Delivery in the UK. Details
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
Only 1 left in stock (more on the way).
Dispatched from and sold by Amazon. Gift-wrap available.
Want it Monday, 28 July? Choose Express delivery at checkout. Details


Amazon Price New from Used from
Kindle Edition 24.71  
Paperback 32.50  
Trade In this Item for up to 1.58
Trade in Java Servlet & JSP Cookbook for an Amazon Gift Card of up to 1.58, which you can then spend on millions of items across the site. Trade-in values may vary (terms apply). Learn more

Book Description

31 Jan 2004 0596005725 978-0596005726 1

With literally hundreds of examples and thousands of lines of code, the Java Servlet and JSP Cookbook yields tips and techniques that any Java web developer who uses JavaServer Pages or servlets will use every day, along with full-fledged solutions to significant web application development problems that developers can insert directly into their own applications.Java Servlet and JSP Cookbook presents real-world problems, and provides concise, practical solutions to each. Finding even one tested code "recipe" that solves a gnarly problem in this comprehensive collection of solutions and best practices will save hours of frustration--easily justifying the cost of this invaluable book.But "Java Servlet and JSP Cookbook" is more than just a wealth of cut-and-paste code. It also offers clear explanations of how and why the code works, warns of potential pitfalls, and directs you to sources of additional information, so you can learn to adapt the problem-solving techniques to similar situations.These recipes include vital topics like the use of Ant to setup a build environment, extensive coverage of the WAR file format and web.xml deployment descriptor, file-uploading, error-handling, cookies, logging, dealing with non-HTML content, multimedia, request filtering, web services, I18N, web services, and a host of other topics that frustrate even the most seasoned developers.For Java web developers of all levels who are eager to put into practice the theory presented in other API-focused books, the solutions presented in this practical book will prove invaluable over and over again. This is painless way for less experienced developers who prefer to learn by doing to expand their skills and productivity, while accomplishing practical solutions to the pressing problems they face every day. More experienced developers can use these recipes to solve time-consuming problems quickly, freeing up their time for the more creative aspects of their work.

Frequently Bought Together

Java Servlet & JSP Cookbook + JavaServer Pages + Java Servlet Programming
Price For All Three: 93.99

Buy the selected items together

Product details

  • Paperback: 748 pages
  • Publisher: O'Reilly Media; 1 edition (31 Jan 2004)
  • Language: English
  • ISBN-10: 0596005725
  • ISBN-13: 978-0596005726
  • Product Dimensions: 4.2 x 17.5 x 23 cm
  • Average Customer Review: 3.5 out of 5 stars  See all reviews (2 customer reviews)
  • Amazon Bestsellers Rank: 579,704 in Books (See Top 100 in Books)
  • See Complete Table of Contents

More About the Author

Over the course of a decades-long writing career, I've written on the environment, software, and fitness. Now fiction-"Barbarous Coasts" is the first novel I've published (literally, self-published). I think the natural world, ecology, and human fitness are deeply entwined. I like spending lots of time in the mountains-skiing, climbing, hiking, thinking.

My next novel, coming early this summer, takes place in the mountains.

Most of my time is spent with my family in Vermont and Massachusetts, USA.

Product Description

About the Author

Bruce W. Perry is an independent software developer and writer. Since 1996, he has developed web applications and databases for various non-profits, design and marketing firms, ad agencies, and digital-music specialists. Before working in the web field, Perry remained tethered to his portable and desktop Macs while writing environmental law books and newsletters. When not hacking or writing, he loves cycling and climbing mountains in the U.S. and Switzerland. He lives in the Newburyport, Massachusetts area with his wife Stacy LeBaron and daughter Rachel.

Excerpt. © Reprinted by permission. All rights reserved.

CHAPTER 17 - Embedding Multimedia in JSPs

17.0 Introduction
Most web sites include some type of multimedia and interactive programs, such as digital videos, digital audio files, Macromedia Flash movies, and Java applets. Therefore, Java web sites often integrate this type of content with servlets and JavaServer Pages (JSPs). This chapter explains the basics of embedding multimedia in Java web components. This process involves including the object and embed tags in your component’s HTML output.

A JSP is the preferred choice for combining multimedia with dynamic content, because you can make the tags that you use to embed the multimedia a part of the JSP’s HTML template text. However, Recipe 17.5 also shows how to include multimedia as part of a servlet’s output.

If the page containing the multimedia content does not have to include any other type of dynamic output, just use a static HTML page instead of executing JSPs and servlets. A static page typically requires fewer server resources to respond to HTML page requests.

17.1 Embedding an Applet in a JSP
Using jsp:plugin

You want to use the jsp:plugin standard action to execute a Java applet with the Java Plug-in software.

Use the jsp:plugin action positioned in the area of a JSP where you want the applet
to appear.

The JSP specification provides a standard action, jsp:plugin, which produces the object and embed tags that are designed to allow browsers to load a Java applet. The action will run the applet using Sun Microsystems’s Java Plug-in or initiate the download of the Plug-in if the user has not yet installed the Plug-in.

The Java Plug-in is designed to execute an applet using Sun Microsystems’s Java 2 Runtime Environment, rather than any Java runtime provided by the browser. The installation of the Java JRE or Software Development Kit automatically installs the Java Plug-in.

Use nested jsp:param elements to provide the applet with any necessary parameter and value pairs. The jsp:param elements must be nested within a single jsp:params element.

Inside This Book (Learn More)
Browse Sample Pages
Front Cover | Copyright | Table of Contents | Excerpt | Index | Back Cover
Search inside this book:

What Other Items Do Customers Buy After Viewing This Item?

Customer Reviews

5 star
2 star
1 star
3.5 out of 5 stars
3.5 out of 5 stars
Most Helpful Customer Reviews
16 of 16 people found the following review helpful
3.0 out of 5 stars More Microwave Meal than Cook Book 6 Jan 2005
I bought this as an intermediate Java programmer wanting to check my understanding and see if I was missing any tricks and move on a bit.
It covers a fairly broad area, and I did find parts of it useful but I was expecting more difficult problems to be addressed. Many examples I had already worked out for myself, such as login routines....
Also the three chapters of the book explains how to (1) write servlets, (3) name them and set up directives and (2) the setup of Tomcat and Web Logic. I wouldnt have expected a cook book to waste time telling you how to turn the oven on. Tomcat could have been dealt with in one page, telling you how to install it, connect to localhost and find the documentation on the start page.
If you are new to Java (with a little basic knowlege) this is a pretty good book. It doesnt waste time and does have code you will find useful.
If like me your looking to move from intermediate to advanced its a good overview, does allow you to check your understanding and consolodate your learning, but wont move you forward.
Comment | 
Was this review helpful to you?
4.0 out of 5 stars Java Servlet & JSP Cookbook 4 Jan 2014
Format:Paperback|Verified Purchase
Great book, filled with many useful examples.
Originally purchased for work to speed up understanding for a new dev project, more than made up for the price of the purchase.
Comment | 
Was this review helpful to you?
Most Helpful Customer Reviews on (beta) 3.8 out of 5 stars  8 reviews
33 of 33 people found the following review helpful
4.0 out of 5 stars Over 130 Hacks! 10 Feb 2004
By W Boudville - Published on
The 'cookbook' in the title means that Perry emphasises what he considers to be many common tasks needed to be done by Java Servlets and JSPs, in a J2EE context. Similar in spirit to OReilly's other books like 'eBay Hacks' and 'google Hacks'. In fact, in the 26 chapters of Perry's book, there are on average over 5 tasks in each that he explains, which are akin to the hacks of the other books. Except here, he gives you over 130 hacks.
He assumes you know the basics of the subject. Certainly, the book does not claim to be a comprehensive listing of the subject's features. But if you satisfy this requirement, you can dive straight into any section of any chapter. Don't have to read this book linearly.
However, if you aren't using Tomcat or BEA WebLogic as containers, then the relevance of the book may, frankly, be more limited. Different containers have slightly different functionalities, and the examples he gives are very specific to those 2 containers. If you are in fact using another, perhaps you can use this book to provide design patterns and inspiration, but not actual code.
84 of 93 people found the following review helpful
1.0 out of 5 stars Hampered by use of custom libraries 7 Sep 2004
By Matthew J. Weaver - Published on
Being an O'Reilly fan it is hard for me to find fault with their no-nonsense approach to technical books, but there is one MAJOR issue I have with this book.

As a developer for a major corporation I cannot use custom libraries for my work, especially when the license ([...]) does not allow for commercial use. Where it would be helpful to see details on creating say, a multipart request class, Bruce Perry instead uses the com.oreilly.servlet.MultipartRequest class to hide much of the functionality (this is just one example).

This makes little or no sense. Developers in the real world need real examples. Hiding the implementation of such under the non-commercial license pretty much ruins much of the potential application of an otherwise well written book. If you buy this book realise that only some of it will actually be useful in the real world.
25 of 27 people found the following review helpful
5.0 out of 5 stars Must-have book for any Servlet/JSP developer 5 Mar 2004
By Vinny Carpenter - Published on
In the great tradition of cookbooks, O'Reilly has published the Java Servlet and JSP Cookbook. This book, written by Bruce W. Perry is a must-own book for anyone working with web applications in the Java space. I've been a Java developer for almost 8 years now and have been working with Servlets since early 1999 and I've learned quite a few things from this book.
The Java Servlet & JSP Cookbook provides more than 200 'recipes' or fully working and documented code snippets that you can directly cut-and-paste in your application. The book starts off with a quick intro to writing servlets and JSP pages. I was very impressed that the first JSP page that you write uses JSTL and is not loaded up with scriptlet code. I am just sick and tired of arguing with people with scriptlets are bad and it's nice to see a book that starts off with JSTL. Kudos Bruce.
Once the intro is complete, you move onto writing deployment descriptors, deployment along with a nice little chapter on Ant. One of the most common question after people deploy JSP based application is the idea of precompiling JSPs for performance reasons. The fifth chapter does a great job of suggesting several methods of precompiling JSPs. I should also mention that the book includes how-to guides for Tomcat and WebLogic, which covers a pretty large landscape of web containers. WebSphere, Resin, Jetty are not directly covered.
The book then moves on and covers topics such as handling Form data via POST/GET, uploading files, cookies, session tracking and URL rewriting. There is also a chapter on JavaScript and how they use JavaScript with servlets. I don't really understand the point of this chapter as most users just need a few cut-n-paste JavaScript for client-side FORM validation. There is also a chapter on streaming non-HTML content such as PDF, audio/video files and others to the browser.
I also liked the chapter of logging in Servlets and JSPs. This chapter includes a nice introduction to Log4j and a nice tag library that uses Log4j under the cover. My favorite chapter in this book was the chapter dealing with authentication. The chapter starts off by talking setting users in Tomcat and then moves into setting up BASIC authentication. The next recipe talks about using Form-based authentication. The chapter is rounded off with a good treatment of the Java Authentication and Authorization service (JAAS). In this chapter, you create your own custom LoginModule and then use JAAS in a servlet and JSP.
There is also a chapter about embedding multimedia content inside JSPs. This is not something I'm really interested in and I just glossed over this chapter. The same goes for the next chapter on manipulation of the HttpRequest. The next chapter does a great job of exploring Servlet Filters, which is a great feature introduced in the Servlet 2.3 specification that hasn't really caught on. Filters are great and the book includes some great examples of how best to use them.
The next section includes chapters on sending, accessing email from servlets along with database access. Most complex application usually will implement some backend service to access database and separate the business logic from the data and the data from the UI, but the included recipes will help get you up and running for simple application.
I really liked the section on custom tag libraries and JSTL. Tag Libraries are a great way to avoid scriptlet code in JSPs. The chapter on JSTL is also fairly comprehensive and includes code snippets for the core, XML, format, and SQL tags. There is also a great section on the Expression Language (EL) which has been migrated from JSTL 1.0 to the JSP 2.0 specification.
I could go on about this book but I won't bore you any longer, assuming you are still reading. I highly recommend this book for anyone doing any type of Web development using Servlet and JSPs. I mentioned this earlier, but I've been writing Servlets and JSPs for the past 5 years and I've learned quite a few things from this book. Add this book to your library today. The code for this book is available on O'Reilly dot com
12 of 12 people found the following review helpful
5.0 out of 5 stars Very good bridge from theory to practical... 15 Mar 2004
By Thomas Duff - Published on
Target Audience
Web developers who are looking for real-life examples of the use of servlets and JSP.
This is a companion-type book that goes beyond strictly reference material to the use of different servlet and JSP features, along with working examples of code to illustrate the concepts.
The book is divided multiple chapters that each cover a different technique or function:
Writing Servlets and JSPs; Deploying Servlets and JSPs; Naming Your Servlets; Using Apache Ant; Altering the Format of JSPs; Dynamically Including Content In Servlets and JSPs; Handling Web Form Data in Servlets and JSPs; Uploading Files; Handling Exceptions in Web Applications; Reading And Setting Cookies; Session Tracking; Integrating JavaScript with Servlets And JSPs; Sending Non-HTML Content; Logging Messages from Servlets and JSPs; Authenticating Clients; Binding, Accessing, and Removing Attributes in Web Applications; Embedding Multimedia in JSPs; Working With The Client Request; Filtering Request and Responses; Managing Email In Servlets and JSPs; Accessing Databases; Using Custom Tag Libraries; Using The JSTL; Internationalization; Using JNDI and Enterprise JavaBeans; Harvesting Web Information; Using the Google and Amazon Web APIs
I really like the O'Reilly Cookbook series. I read a lot as part of my ongoing study, and often it's easy to understand conceptually what is going on. But making the jump to practical solutions can be difficult at times. The Cookbook series gets plenty of use on my bookshelf as I do my day to day coding. And when it comes to servlet and JSP coding as I continue to learn more about Websphere Application Server, this book will surely become dog-eared like the rest of them. Bruce Perry has done a great job.
As with most Cookbook titles, each chapter in the Servlet And JSP Cookbook is made up of a number of Problem/Solution/Discussion groupings. This format proposes a coding problem, states the solution to solve it, and then devotes the necessary space to discuss the solution both with text and code. By using this format, you can think through a working solution and determine how to apply that technique to your own problem. Perry covers a wide range of problems that will help both the beginner and the experienced coder. For beginners, the solutions for setting cookies with servlets and JSPs may be just what you need to get started. Experienced people will find the internationalization and JNDI/Enterprise JavaBeans solutions useful. I appreciate the fact that coders of all experience levels can get something out of this book.
The only caveat I have on this book is that it is very focused on the Tomcat and WebLogic web application servers. If that's your platform of choice, you're going to get everything this book has to offer. For me, I'm partial to the WebSphere platform. While I will benefit from a lot of this book, there are chapters that will have no appeal to me, such as using the Ant package. I will also need to pay attention to the coding examples to make sure that the techniques are coded correctly for my platform of choice. Even with that warning, I would still highly recommend this book to all coders working in this area.
This is definitely a title that will be useful to you as you learn more about servlet and JSP programming. It will give you the ideas you need to solve real business problems you'll encounter as a developer.
10 of 11 people found the following review helpful
5.0 out of 5 stars Precisely the book I've been dreaming of... 7 Oct 2004
By Brock Seyler - Published on
This book is exactly what it claims to be: a general reference to hundreds of "everyday" situations Java Web developers face. Just as any cookbook, it doesn't go into the "deepest" details about every little thing, and it does give examples of ways to not reinvent the wheel. Some reviewers see this as worthy of only 1 star... This is only a 1 star book for readers who like to reinvent the wheel and waste time on unnecessary details... if you're like me and have deadlines to meet, you'll find what you need here quickly and efficiently.
Were these reviews helpful?   Let us know
Search Customer Reviews
Only search this product's reviews

Customer Discussions

This product's forum
Discussion Replies Latest Post
No discussions yet

Ask questions, Share opinions, Gain insight
Start a new discussion
First post:
Prompts for sign-in

Search Customer Discussions
Search all Amazon discussions

Look for similar items by category