简体   繁体   中英

How can I use Expression Language in a jsp file? What implicit objects are available?

I always confuse / forget how to use Expression Language in a JSP file.

Can you give some examples?

What implicit object does EL come with?

What implicit object does EL come with?

all attributes set in request, page context, session, servlet context are impliticly available

plus request parameter map available via ${param.paramName}

I will edit my answer and add some better explanations:

There are 11 implicit objects. 10 of them are simply Maps and of those 10, 4 of them are sessions:

pageScope
requestScope
sessionScope
applicationScope

Then there comes parameters:

param
paramValues

These provide access to the request parameters. The param variable is a Map and contains only the first value from any parameter with multiple values.(This is similar to getParameter from ServletRequest). Map paramValues contains all the values of every parameter.(This is similar to getParameterValues from ServletRequest).

Ok then comes:

header
headerValues

2 more maps are:

initParams
cookie

initParam is a Map containing all the context init paramters from the ServletContext instance for this application.

cookie on the other hand is a Map containing all the cookies that the user's browser sent along with the request.

So there is 1 more implicit object left, which is not a Map:

pageContext

There you go..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM