I use GlassFish 4.1 web profile which as I understand uses EL 3.0. I did everything as was explained here - https://stackoverflow.com/a/3735006/5057736 however my implementation of this solution doesn't work.
This is my constant class
public class CommonKeys {
public static final String TITLE = "SOME_KEY";
}
This is how I set attribute:
request.setAttribute(CommonKeys.TITLE, "TEST");
This is my jsp:
Method 1:
Method 2:${requestScope[CommmonKeys.TITLE]}
Method 3:${requestScope["SOME_KEY"]}
This is the output I get
Method 1:TEST
Method 2:
Method 3:TEST
Why does Method 2 not work?
解决方案
Method 2:${requestScope[TITLE]}
Change your code as per above, should be working fine. It works for me.