Chapter 8. Scriptless JSP: Script-free pages

image with no caption

Do your web page designers really have to know Java? Is that fair? Do they expect server-side Java 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 flexible 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!

OBJECTIVES

Building JSP pages using the Expression Language (EL) and Standard Actions

7.1

Write a code snippet using top-level variables in the EL. This includes the following implicit variables: pageScope, requestScope, sessionScope, and applicationScope; param and paramValues; header and headerValues; cookies; and initParam.

7.2

Write a code snippet using the following EL operators: property access (the . operator), collection access (the [] operator).

7.3

Write a code snippet using the following EL operators: aritmetic operators, relational operators, and logical operators.

7.4

For EL functions: Write a code snippet using an EL function; identify or create the TLD file structure used to declare an EL function; and identify or create a code example to define an EL function.

8.1

Given a design goal, create a code snippet using the following standard actions: jsp:useBean (with attributes: ‘id’, ‘scope’, ‘type’, and ‘class’), jsp:getProperty, and jsp: setProperty (with all attribute combinations).

8.2

Given a design goal, create a code snippet using the following standard actions: jsp:include, jsp:forward, and jsp:param.

6.7

Given a specific design goal for including a JSP segment in another page, write the JSP code that uses the most appropriate inclusion mechanism (the include directive or the <jsp:include> standard action).

Coverage Notes:

All of the objectives in this section are covered completely in this chapter. And it’s a big one. Take your time in this chapter; there’s a lot of picky details to go through.

In this chapter, we cover BOTH include mechanisms: <jsp:include> from objective 8.2, and the include page directive from objective 6.7 (most of the objectives in section 6 were covered in the previous chapter on JSPs).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset