The language of expressions. Dominant variable

On the JSP page, we can access attributes using this: ${name} . But if we in sevlet do the following:

 req.getSession.setAttribute("name", sessionName ); getServletContext().setAttribute("name", sevletContextName) req.setAttribute("name", reqName); 

then which JSP variable will be available when used?

$ {name}

+4
source share
1 answer

JSP EL scans the page, then requests, then the session, then the application.

If you want to access the session explicitly, use

 ${sessionScope.name} 

In the context of a servlet, use

 ${applicationScope.name} 

(and similarly for pageScope and requestScope )

+6
source

Source: https://habr.com/ru/post/1391089/


All Articles