Head First Servlets Jsp 2nd Edition Free

Head First Servlets Jsp 2nd Edition Free 3,5/5 1118votes

Imagine a world without eBay.unthinkable! How would you get that Farrah Fawcett poster, retired Beanie Baby, or first-edition pet rock? Handling over a gazillion (OK, we exaggerate--it's actually only 1 billion) page views each day, server-side Java makes eBay work. Isn't it time you learned the latest (J2EE 1.4) versions of Servlets & JSPs? This book will get you way up to speed on the technology you'll know it so well, in fact, that you can pass the Sun Certified Web Component Developer (SCWCD) 1.4 exam. If that's what you want to do, that is.

Maybe you don't care about the exam, but need to use Servlets & JSPs in your next project. You're working on a deadline. You're over the legal limit for caffeine.

You can't waste your time with a book that makes sense only AFTER you're an expert (or worse one that puts you to sleep). Head First Servlets and JSP's brain-friendly approach drives the knowledge straight into your head (without sharp instruments). You'll interact with servlets and JSPs in ways that help you learn quickly and deeply. It may not be The Da Vinci Code, but quickly see why so many reviewers call it 'a page turner'.

Most importantly, this book will help you use what you learn. It won't get you through the exam only to have you forget everything the next day. Learn to write servlets and JSPs, what makes the Container tick (and what ticks it off), how to use the new JSP Expression Language (EL), what you should NOT write in a JSP, how to write deployment descriptors, secure applications, and even use some server-side design patterns. Can't talk about Struts at a cocktail party? That'll change. You won't just pass the exam, you will truly understand this stuff, and you'll be able to put it to work right away. This new exam is tough--much tougher than the previous version of the SCWCD.

The authors of Head First Servlets and JSP know: they created it. (Not that it EVER occurred to them that if they made the exam really hard you'd have to buy a study guide to pass it.) The least they could do is give you a stimulating, fun way to pass the thing. If you're one of the thousands who used Head First EJB to pass the SCWCD exam, you know what to expect!

'Head First Servlets & JSP 2nd Edition (Engels)' door Bryan Basham, Kathy Sierra, Bert Bates - Onze prijs: €47,58 - Verwachte levertijd ongeveer 8 werkdagen. Amazon.com: Head First Servlets and JSP, Second Edition eBook: Bert Bates, Kathy Sierra, Bryan Basham: Kindle Store.

Head First Servlets Jsp 2nd Edition Free

Table of contents 1 Why use Servlets & JSPs Web applications are hot. How many GUI apps do you know that are used by millions of users worldwide? As a web app developer, you can free yourself from the grip of deployment problems all standalone apps have, and deliver your app to anyone with a browser. But you need servlets and JSPs.

Because plain old static HTML pages are so, well, 1999. Learn to move from web site to web app. Exam objectives 2 What web servers and clients do, and how they talk? 4 Two-minuteguide to HTML 7 What is the HTTP protocol? 10 Anatomy of HTTP GET and POST requests and HTTP responses 16 Locating web pages using URLs 20 Web servers, static web pages, and CGI 24 Servlets Demystified: write, deploy, and run a servlet 30 JSP is what happened when somebody introduced Java to HTML 34 Web app architecture Servlets need help.

When a request comes in, somebody has to instantiate 2 the servlet or at least allocate a thread to handle the request. Somebody has to call the servlet’s doPost() or doGet() method. Somebody has to get the request and the response to the servlet. Somebody has to manage the life, death, and resources of the servlet. In this chapter, we’ll look at the Container, and we’ll take a fi rst look at the MVC pattern. Exam Objectives 38 What is a Container and what does it give you?

39 How it looks in code (and what makes a servlet) 44 Naming servlets and mapping them to URLs using the DD 46 Story: Bob Builds a Matchmaking Site ( and MVC intro) 50 A Model-View-Controller(MVC) overview and example 54 A “working” Deployment Descriptor (DD) 64 How J2EE fits into all this 65. Table of contents Mini MVC tutorial Create and deploy an MVC web app. It’s time to get your hands dirty 3 writing an HTML form, a servlet controller, a model (plain old Java class), an XML deployment descriptor, and a JSP view. Time to build it, deploy it, and test it. But fi rst, you need to set up your development environment.

Next, you need to set up your deployment environment following the servlet and JSP specs and Tomcat requirements. True, this is a small app. But there’s almost NO app that’s too small to use MVC. Exam Objectives 68 Let’s build an MVC application; the first design 69 Create the development and deployment environments 72 Create and test the HTML for the initial form page 75 Create the Deployment Descriptor (DD) 77 Create, compile, deploy, and test the controller servlet 80 Design, build, and test the model component 82 Enhance the controller to call the model 83 Create and deploy the view component (it’s a JSP) 87 Enhance the controller servlet to call the JSP 88 Being a Servlet Servlets need help. When a request A servlet’s job is to take a client’s request 4 and send back a response.

The request might be simple: “ get me the Welcome page.” Or it might be complex: “ Complete my shopping cart check-out.”The request carries crucial data, and your servlet code has to know how to fi nd it and how to use it. And your servlet code has to know how to send a response. Exam Objectives 94 A servlet’s life in the Container 95 Servlet initialization and threads 101 A Servlet’s REAL job is to handle GET and POST requests. 105 The story of the non-idempotentrequest 112 What determines whether you get a GET or POST request? 117 Sending and using parameter(s) 119 So that’s the Request.

Now let’s see the Response 126 You can set response headers, you can add response headers 133 Servlet redirect vs. Request dispatcher 136 Review: HttpServletResponse 140. Table of contents Being a web app No servlet stands alone. In today’s modern web app, many components 5 work together to accomplish a goal. You have models, controllers, and views.

You have parameters and attributes. You have helper classes. But how do you tie the pieces together? How do you let components share information? How do you hide information?

How do you make information thread-safe? Your job may depend on the answers.

Exam Objectives 148 Init Parameters and ServletConfig to the rescue 149 How can a JSP get servlet init parameters? 155 Context init parameters to the rescue 157 Comparing ServletConfig with ServletContext 159 She wants a ServletContextListener 166 Tutorial: a simple ServletContextListener 168 Compile, deploy, and test your listener 176 The full story, a ServletContextListener review 178 Eight Listeners: they’re not just for context events.

180 What, exactly, is an attribute? Entrapass Special Edition Serial Number. 185 The Attribute API and the dark side of attributes 189 Context scope isn’t thread-safe!

192 The problem in slow motion. 193 Trying out Synchronization 195 Are Session attributes thread-safe?

198 The SingleThreadModel 201 Only Request attributes and local variables are thread-safe! 204 Request attributes and Request dispatching 205. Table of contents Conversational state Web servers have no short-termmemory. As soon as they send you 6 a response, they forget who you are. The next time you make a request, they don’t recognize you.

Depapepe Passion Of Gradation Raritan there. They don’t remember what you’ve requested in the past, and they don’t remember what they’ve sent you in response. But sometimes you need to keep conversational state with the client across multiple requests. A shopping cart wouldn’t work if the client had to make all his choices and then checkout in a single request. Exam Objectives 224 It’s supposed to be a conversation, (how sessions work) 226 Session IDs, cookies, and other session basics 231 URL rewriting: something to fall back on 237 When sessions get stale; getting rid of bad sessions 241 Can I use cookies for other things, or are they only for sessions? 250 Key milestones for an HttpSession 254 Don’t forget about HttpSessionBindingListener 256 Session migration 257 Listener examples 261 7 Being a JSP A JSP becomes a servlet. A servlet that you don’t create. The Container looks at your JSP, translates it into Java source code, and compiles it into a full-fledged Java servlet class.

But you’ve got to know what happens when the code you write in the JSP is turned into Java code. You can write Java code in your JSP, but should you? And if not Java code, what do you write? How does it translate into Java code? We’ll look at six different kinds of JSP elements—eachwith its own purpose and, yes, unique syntax. You’ll learn how, why, and what to write in your JSP.

And you’ll learn what not to write. Exam Objectives 282 Create a simple JSP using “out” and a page directive 283 JSP expressions, variables, and declarations 288 Time to see a JSP-generatedservlet 296 The out variable isn’t the only implicit object. 298 The Lifecycle and initialization of a JSP 306 While we’re on the subject.

Let’s talk more about the three directives 314 Scriptlets considered harmful? Here’s EL 317 But wait. We haven’t seen: actions 323. Table of contents 8 Script-freepages Do your web page designers really have to know Java? Do they expect server-sideJava programmers to be, say, graphic designers?

And even if it’s just you on the team, do you really want a pile of bits and pieces of Java code in your JSPs? Can you say, “maintenance nightmare”? Writing scriptless pages is not just possible, it’s become much easier and more fl exible with the new JSP 2.0 spec, thanks to the new Expression Language (EL).

Patterned after JavaScript and XPATH, web designers feel right at home with EL, and you’ll like it too (once you get used to it). But there are some traps. EL looks like Java, but isn’t. Sometimes EL behaves differently than if you used the same syntax in Java, so pay attention!

Exam Objectives 344 When attributes are beans 345 Standard actions: useBean, getProperty, setProperty 349 Can you make polymorphic bean references? 354 The param attribute to the rescue 360 Converting properties 363 Expression Language (EL) saves the day! 368 Using the dot (.) operator to access properties and map values 370 The [] gives you more options (Lists, arrays.) 372 More dot and [ ] operator details 376 The EL implicit objects 385 EL functions, and handling “null” 392 Reusable template pieces—twokinds of “include” 402 The standard action 416 She doesn’t know about JSTL tags (a preview) 417 Reviewing standard actions and include 417.

Table of contents 9 Custom tags are powerful Sometimes you need more than EL or standard actions. What if you want to loop through the data in an array, and display one item per row in an HTML table? You know you could write that in two seconds using a for loop in a scriptlet. But you’re trying to get away from scripting.

When EL and standard actions aren’t enough, you can use custom tags. They’re as easy to use in a JSP as standard actions. Even better, someone’s already written a pile of the ones you’re most likely to need, and bundled them into the JSP Standard Tag Library (JSTL). In this chapter we’ll learn to use custom tags, and in the next chapter we’ll learn to create our own. Exam Objectives 440 Looping without scripting 446 Conditional control with and 451 Using the and tags 455 With, there are now three ways to include content 460 Customizing the thing you include 462 Doing the same thing with 463 for all your hyperlink needs 465 Make your own error pages 468 The tag. Like try/catch. Sort of 472 What if you need a tag that’s NOT in JSTL?

475 Pay attention to 480 What can be in a tag body 482 The tag handler, the TLD, and the JSP 483 The taglib is just a name, not a location 484 When a JSP uses more than one tag library 487. When even JSTL isn’t enough. Sometimes JSTL and standard actions aren’t enough. When you need something custom, and you don’t want to go back to scripting, you can write your own tag handlers. That way, your page designers can use your tag in their pages, while all the hard work is done behind the scenes in your tag handler class. But there are three different ways to build your own tag handlers, so there’s a lot to learn.

Of the three, two were introduced with JSP 2.0 to make your life easier (Simple Tags and Tag Files). Exam Objectives 500 Tag Files: like include, only better 502 Where the Container looks for Tag Files 509 Simple tag handlers 513 A Simple tag with a body 514 What if the tag body uses an expression? 519 You still have to know about Classic tag handlers 529 A very small Classic tag handler 531 The Classic lifecycle depends on return values 536 IterationTag lets you repeat the body 537 Default return values from TagSupport 539 The DynamicAttributes interface 556 With BodyTag, you get two new methods 563 What if you have tags that work together?

567 Using the PageContext API for tag handlers 577 Deploying your web app Finally, your web app is ready for prime time. Your pages are polished, your code is tested and tuned, and your deadline was two weeks ago.

But where does everything go? So many directories, so many rules.

What do you name your directories? What does the client think they’re named? What does the client actually request, and how does the Container know where to look? Exam Objectives 602 Key deployment task, what goes where? 603 WAR files 612 How servlet mapping REALLY works 616 Configuring welcome files in the DD 622 Configuring error pages in the DD 626 Configuring servlet initialization in the DD 628 Making an XML-compliantJSP: a JSP Document 629. You can also control the response.

And best of all, the servlet remains clueless. It never knows that someone stepped in between the client request and the Container’s invocation of the servlet’s service() method. What does that mean to you? More vacations. Because the time you would have spent rewriting just one of your servlets can be spent instead writing and confi guring a fi lter that has the ability to affect all of your servlets. Want to add user request tracking to every servlet in your app? Manipulate the output from every servlet in your app?

And you don’t even have to touch the servlet. Table of contents Keep it secret, keep it safe Your web app is in danger. Trouble lurks in every corner of the network. You don’t want the Bad Guys listening in to your online store transactions, picking off credit card numbers. You don’t want the Bad Guys convincing your server that they’re actually the Special Customers Who Get Big Discounts. And you don’t want anyone (good OR bad) looking at sensitive employee data. Does Jim in marketing really need to know that Lisa in engineering makes three times as much as he does?

Exam Objectives 650 The Big 4 in servlet security 653 How to Authenticate in HTTP World 656 Top Ten Reasons to do your security declaratively 659 Who implements security in a web app? 660 Authorization roles and constraints 662 Authentication: four flavors 677 The FOUR authentication types 677 Securing data in transit: HTTPS to the rescue 682 Data confidentiality and integrity sparingly and declaratively 684 Exam Objectives 702 Building the request tracking filter 707 A filter’s life cycle 708 Declaring and ordering filters 710 Compressing output with a response-sidefilter 713 Wrappers rock 719 The real compression filter code 722 Compression wrapper code 724. Enterprise design patterns Someone has done this already. If you’re just starting to develop web applications in Java, you’re lucky. You get to exploit the collective wisdom of the tens of thousands of developers who’ve been down that road and got the t-shirt.Using both J2EE-specific and other design patterns, you can can simplify your code and your life. And the most signifi cant design pattern for web apps, MVC, even has a wildly popular framework, Struts, that’ll help you craft a fl exible, maintainable servlet Front Controller.

You owe it to yourself to take advantage of everyone else’s work so that you can spend more time on the more important things in life. Exam Objectives 738 Hardware and software forces behind patterns 739 Review of softweare design principles.

744 Patterns to support remote model components 745 Overview of JNDI and RMI 747 The Business Delegate is a “go-between” 753 Time for a Transfer Object? 759 Business tier patterns: quick review 761 Our very first pattern revisited. It’s Struts (and FrontController) in a nutshell 767 Refactoring the Beer app for Struts 770 Review of patterns 778 A The final Coffee Cram Mock Exam. 69 questions. The tone, topics, and diffi culty level are all virtually identical to the real exam. Final mock exam 791 i Answers 828 Index 865.