| Section 10 |
|---|
10.1 For any of the following tag functions, match the correctly constructed tag, with attributes and values as appropriate, with the corresponding description of the tag's functionality:
|
| 10.2 Given JSP page attribute scopes: request, session, application, identify the equivalent servlet code. |
| 10.3 Identify techniques that access a declared JavaBean component. |
10.1 For any of the following tag functions, match the correctly constructed tag, with attributes and values as appropriate, with the corresponding description of the tag's functionality:
<jsp:useBean> <jsp:useBean id="connection"class="com.myco.myapp.myBean" scope="page" /> - create if bean doesn't exist <jsp:useBean id="connection" beanName="com.myco.myapp.myBean.ser" /> - create from a serialized object <jsp:useBean id="connection" type="com.myco.myapp.myBean" /> - Bean should already exist <jsp:useBean id="name" scope="page|request|session|application" typeSpec /> typeSpec ::= class="className" | class="className" type="typeName" | type="typeName" class="className" | beanName="beanName" type="typeName" | type="typeName" beanName="beanName" | type="typeName"
<jsp:useBean id="name" scope="page|request|session|application" typeSpec >
body - usually this will be scriptlets or jsp:setProperty actions
</jsp:useBean>
<jsp:getProperty>
<jsp:getProperty name="beanName" property="propName" />
<jsp:setProperty>
<jsp:setProperty name="bean1" property="*" />
-- all request parameters will be set in bean's properties (with matching names)
<jsp:setProperty name="bean2" property="user " param="username " />
-- request parameter 'username' will be set to 'user' property of the bean
<jsp:setProperty name="bean2" property="user " />
-- request parameter 'user' will be set to 'user' property of the bean (since no param specified, it is assumed to have the same name as the property)
<jsp:setProperty name="bean2" property="user " value="me" />
<jsp:setProperty name="bean2" property="user " value="<%=session.getAttribute("user") %>" />
-- new value can be specified with an expression. If it's an expression no conversion is performed, else standard conversion is performed.
Note: value cannot be used in conjunction with param
10.2 Given JSP page attribute scopes: request, session, application, identify the equivalent servlet code.
request - HTTPServletRequest session - HTTPServletRequest.getSession() : HTTPSession application - GenericServlet.getServletContext() or GenericServlet.getServletConfig().getServletContext()
10.3 Identify techniques that access a declared JavaBean component.
A declared JavaBean can also be accessed using: (the name specified in the id attribute of <jsp:useBean>)
Scriptlets Expressions Custom Tags