EL Is Patterned After Javascript and Xpath
EL Is Patterned After Javascript and Xpath
2. Why would this be required if you want to set the attribute if its not there
using <jsp: setProperty>
3. <jsp:useBean> can have body
4. With this body the generated servlet code will have if in generated code.
5. For use with JSP the property type should be either String or int, else it would
be a valid bean but wont work with JSP standard actions you have to rely on
scripting.
6. Polymorphic bean references :
a. Make person abstract
7.
9. What if the request goes straight from html to jsp and u want to set some
bean property from request
11.param attribute is not necessary : the input field name becomes request
parameter name so if you match this name with bean property name you
dont have to specify param attribute
12.using * for all fields : if you match all fields with property names then it
gets even better.
EL to the rescue
2. THE [] operator
a. [] becomes useful when the left side is anything other than map or
bean
b. That means the thing the right can be number ,or anything that
resolves to a number or an identifier that does not fit the java naming
rules. For example you might have a Map key thats a String with dots
in the name(com.foo.trouble).
is
7. The same is true for JSP expressions and jsp:getProperty standard action
EL implicit objects
1. Request parameters in EL
NO no nooooooooo
4. Why not?
a. The implicit requestScope is not a request object its a map containing
request scoped attributes.
b. What we want(HTTP method) is a property of request object.
5. Use pageContext
6. Why use scope objects, if EL looks thru all the scopes,is it just in case there is
a naming conflict or something more?
a. initParam.mainEmail
3. The EL initParam is not for params confihured using<init-param>
Note : the uri in the taglib directive tells the container the name of the TLD so the
container knows which method to call when JSP invokes EL function.
This uri matches the one specified in TLD
Points to remember :
1. Its not important that the method the EL invokes shud return something
2. The container finds the TLD by looking into WEB-INF and WEB-INF/lib, if .tld
are in jar
3. EL can have arguments , but the args must havefully qualified names
<function-signature>
int rollDice(java.util.Map)
</function-signature>
An exercise :
EL is null friendly
Layout templates
Reusable template pieces using include directive and jsp standard action
<jsp:include>
1. The include directive tells the container : copy everthing in this file and paste
it into this file, right here.
2. <%@ include file=header.jsp %>
3. <jsp: include page=header.jsp />
Points :
1.
2. The include directive is position sensitive.
3.
4. How to remember where file and where page.
a. Directive happens at translation time when container cares about files
b. Action happens at runtime when container cares about pages.
5. The included page can be dynamic but it has limitations : it cannot set
response status code and it cannot set headers. If u try u wont get error but
it just wont happen