If that's what you want. This book gets readers up to speed on the technology necessary to write servlets and JSPs, what makes the Container tick, how to use the new JSP Expression Language EL , how to write deployment descriptors, and even how to use some server-side design patterns.
If that's what you want to do, that is. Maybe you don't care about the exam, but need to use servlets. Opens with a chapter discussing the details of the SCWCD certification exam and process, then offers an overview of web applications as well as the servlet and JSP technologies, and, finally, covers each of the exam's thirteen objectives.
All Users. Learning a complex new language is no easy task especially when it s an object-oriented computer programming language like Java. You might think the problem is your brain. It seems to have a mind of its own, a mind that doesn't always want to take in the dry, technical stuff.
A guide to JavaBeans provides more than two hundred questions and answers to help readers pass the Sun Certified Business Component Developer exam. Covering Servlet 3. Architects of buildings and architects of software have more in common than most people think.
Sometimes EL behaves differently than if you used the same syntax in Java, so pay attention! Exam Objectives When attributes are beans Standard actions: useBean, getProperty, setProperty Can you make polymorphic bean references? 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. 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? 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. URL-related: url. That means each web app needs a copy. 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.
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. A c:out tag without an escapeXML attribute is just the. She noticed that we were using EL everywhere to output strings entered by users. She said this was a security risk and recommended we output all user strings using the c:out tag. What gives?
A: Your consultant was right. The security risk she is referring to is called cross-site hacking or cross-site scripting. The cracker includes viral JavaScript code in the comment. This previnterpreted by A: Good question. The c:out tag is smart, and it recognizes when the value is null and can perform a special action. 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. 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. And imagine that members can also post comments, but non-member guests cannot. 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: you have a car sales web site, and page asks the user what he you want to customize the headline that shows up on each page, based on a user attribute set up earlier in the session. We are, after all, trying to sell him a car the pages that talk about and become obscenely wealthy.
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. 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: var and target. 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: with or without a body. This happens even if start looking at pag e, a scope, it will Duck, or a Broccoli. Even attribute. Q: 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.
A: 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 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.
0コメント