technology you - Selection from Head First Servlets and JSP, 2nd Edition [ Book] ISBN: View table of Maybe you don't care about the exam, but need to use servlets and JSPs in your next project. You're working on a . Want to get to know the latest (J2EE ) versions of Servlets and JSPs so well that you can pass the Sun Certified Web Component Developer (SCWCD) Читать работу online по теме: Head First Servlets and JSP, Second Edition. ВУЗ: НТУУ КПИ. ISBN: [M]. This book is.
|Language:||English, Spanish, Dutch|
|ePub File Size:||19.78 MB|
|PDF File Size:||20.61 MB|
|Distribution:||Free* [*Regsitration Required]|
March Second Edition. Head First Servlets and JSP™, Second Edition, and related trade dress are trademarks of O'Reilly ISBN: Automatically exported from lesforgesdessalles.info - dieforfree/ edsebooks. O'Reilly Head First Servlets and JSP (2nd Editi.. Pages·· MB·4, Downloads. Head First Servlets and JSP™, Second Edition, and related trade.
RMI makes life easy What we want This is my horse. 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. And your servlet code has to know how to send a response. But where does everything go? If you bod y.
Exam Objectives When attributes are beans 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. No problem.
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. Of the three, two were introduced with JSP 2.
Exam Objectives Tag Files: 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 actually request, and how does the Container know where to look? Exam Objectives Key deployment task, what goes where? Trouble lurks in every corner of the network.
Does Jim in marketing really need to know that Lisa in engineering makes three times as much as he does? HTTPS to the rescue Data confidentiality and integrity sparingly and declaratively 13 The power of filters Filters let you intercept the request. And if you can intercept the request, you can also control the response.
And best of all, the servlet remains clueless. What does that mean to you? More vacations. Want to add user request tracking to every servlet in your app? Manipulate the output from every servlet in your app? Exam Objectives Hardware and software forces behind patterns Review of softweare design principles MVC Yes! This is it. We know.
Sometimes you need more than EL or standard actions. The JSTL 1. Having access to 9. JSTL v1. That means each web app needs a copy. Copy the files from the Tomcat examples at: I want to show one element per row in a table EL and standard actions are limited What happens when you bump into a brick wall? Developers usually want way more standard actions or—even better—the ability to create their own actions.
And you can. For the JSP page creator, custom tags are much easier to use than scripting. For the Java programmer, however, building the custom tag handler the Java code invoked when a JSP uses the tag is tougher. Still, there could be times when you need something from, say, a custom tag library developed specifically for your company. The case of the disappearing HTML reprised On page , you saw how EL sends the raw string of content directly to the response stream: Tip of the Day: What we need is a way to convert those angle brackets into something the browser will render as angle brackets, and there are two ways to do this.
You can explicitly declare the conversion of XML entities If you know or think you might run into some XML entities that need to be displayed, and not just rendered, you can use the escapeXml attribute on c: Setting this to true means that any XML will be converted to something the web browser will render, angle brackets and all: In that case, you can turn off XML conversion: Which HTML special characters are converted?
Character Character Entity Code A: It turns out this conversion is rather simple. She noticed that we were using EL everywhere to output strings entered by users.
The c: That action is to provide a default value Just add a default attribute, and provide the value you want to print if your expression evaluates to null: This value is output if the value attribute evaluates to null.
Servlet code Mak e a St set the arrring of movie names, ay as a requ est attribuatnd e. What you want http: This table has element in a ne per row. The trick is telling the table how many rows and columns you want. The key feature is that the tag assigns each element in the collection to the variable you declare with the var attribute. The variab value changes with each iter collection. An array of arrays? In this example, we put String arrays into an ArrayList, then make the ArrayList a request attribute.
The JSP has to loop through the ArrayList to get each String array, then loop through each String array to print the actual elements of the array. ArrayList ; movieList. Watch it! No fou r— ibutes like the other book tells you where to get the specs covered on the to which you can bind attr ses sio n, and application. Tag scope exam. An example is the block scope in plain old love: And imagine that members can also post comments, but non-member guests cannot.
What members see: What NON-members see: What if you want to do one thing if the condition is true, and a different thing if the condition is false? In other words, what if we want to show either one thing or the other, but nobody will see both? The first But now imagine this scenario: We are, after all, trying to sell him a car the pages that talk about and become obscenely wealthy. Somewhere later in the session: Now you can stop even if you do st cu it his in t drive insanely fast.
We have the best speed sensors of any car this size. We can almost do it, using something like: But what if you want to set a value in a Map? What if you want to make a new entry in a Map? Or what if you simply want to create a new request-scoped attribute?
Set comes in two flavors: The var version is for setting attribute variables, the target version is for setting bean properties or Map values. Each of the two flavors comes in two variations: This happens even if start looking at pag e, a scope, it will Duck, or a Broccoli. Even attribute. That me: Why would I use the body version instead of the no-body version? It looks like they both do exactly the same thing. It might be a long and complex is page scope.
If you put in a String look in the page scope space. We hear you. Once again, nobody asked US. That feels wrong. But remember, set does a remove only when you pass in a null value. The answers are at the end of the chapter.
The include directive use you do have different word for the attribu s ma kes sen se, wh en you think about it The imported chunk uses a reference to an image that is also on Server B. This is my horse. Welcome to our Web Services Support Group.
How can you guarantee session tracking from a JSP He missed the point How can I get the session ID added to Ahhh It does URL rewriting automatically. First we had to get the session either the existing one or a new one. The Container wants to use a cookie—it wants to include a unique cookie with the response, and then the client will send that cookie back with each subsequent request.
Except one problem Then what? Query stringacpaes, for example, Uh-oh You do NOT want your clients to see this: You can design a custom page to handle errors, then use the page directive to configure it. And what if I want a different error page depending on the error? You can declare error pages in the DD for the entire web app, and you can even configure different error pages for different exception types, or HTTP error code types , , etc.
That way you can show the client different error pages specific to the type of the problem that generated the error.
Declaring a catch-all error page This applies to everything in your web app—not just JSPs. You can override it in individual JSPs by adding a page directive with an errorPage attribute. Master the c: You don't just pass the new J2EE 1. Head First Servlets and JSP doesn't just give you a bunch of facts to memorize; it drives knowledge straight into your brain. You'll interact with servlets and JSPs in ways that help you learn quickly and deeply. And when you're through with the book, you can take a brand-new mock exam, created specifically to simulate the real test-taking experience.
Stay ahead with the world's most comprehensive technology and business learning platform. With Safari, you learn the way you learn best.
Get unlimited access to videos, live online training, learning paths, books, tutorials, and more. Start Free Trial No credit card required. View table of contents. Start reading. Intro Who is this book for? Who should probably back away from this book? And we know what your brain is thinking Metacognition: Intro and Overview: Everybody wants a web site What does your web server do? What does a web client do?
What is the HTTP protocol? All the pieces. On one page.
High-Level Overview: Web App Architecture What is a Container? What if you had Java, but no servlets or Containers? What does the Container give you?
Bob Builds a Matchmaking Site He starts to build a bunch of servlets Hands-on MVC: Creating your development environment Creating the deployment environment Our roadmap for building the app The HTML for the initial form page Deploying and testing the opening page Mapping the logical name to a servlet class file The first version of the controller servlet Compiling, deploying, and testing the controller servlet Building and testing the model class Enhancing the servlet to call the model, so that we can get REAL advice There is still so much to learn.
Request and Response: In the beginning: Servlet code to download the JAR Whoa. Servlet redirect makes the browser do the work Using relative URLs in sendRedirect A request dispatch does the work on the server side Redirect vs.
Request Dispatch Review: HttpServletResponse Coffee Cram: Mock Exam Chapter 4 Coffee Cram: Chapter 4 Answers 5. Attributes and Listeners: What about the way we did it with the beer app?
We passed the model info to the JSP using a request attribute Setting a request attribute works What she really wants is a listener. She wants a ServletContextListener Tutorial: Attributes are not parameters! The Three Scopes: But then something goes horribly wrong The problem in slow motion How do we make context attributes thread-safe?
Are Session attributes thread-safe?
Protect session attributes by synchronizing on the HttpSession SingleThreadModel is designed to protect instance variables But how does the web container guarantee a servlet gets only one request at a time? Which is the better STM implementation? Only Request attributes and local variables are thread-safe! Coffee Cram: Mock Exam Chapter 5 Coffee Cram: Chapter 5 Answers 6.
Session Management: How sessions work One problem Cookies The best part: What if I want to know whether the session already existed or was just created? URL rewriting: Mock Exam Chapter 6 Coffee Cram: Chapter 6 Answers 7.