Attribute naming convention resulting in long EL expressions on a JSP page

I write many JSP pages for different views. These JSPs retrieve request scope attributes that have very long names to prevent overlapping. Example:

request.getAttribute("domain1.subdomain1.subdomain11.subdomain111.attributeName"); 

The equivalent in EL would be:

 ${requestScope['domain1.subdomain1.subdomain11.subdomain111.attributeName']} 

Sometimes my EL expressions are very long (for example, when I use 3 different JavaBeans to create an HTML tag or call a javascript function).

My question is whether the solution I found is a good software solution. Given the fact that each view has its own page scale, at the beginning of my JSP I want to put

 <c:set var="attributeName" scope="page" value="${requestScope['domain1.subdomain1.subdomain11.subdomain111.attributeName']}" 

And then in my EL expressions I will use

 ${pageScope["attributeName"]} 

Wouldn't that lead to confusion in the actual attribute area when reading JSP code?

+6
source share
1 answer

It seems that you are creating an alias for the long variable name; which is normal.

0
source

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


All Articles