I was facing the same problem. The problem persists because you are using a web server that is by default configured to compile JSP files via source 1.5. All you need to specify is custom target and compiled java versions.
If you are using tomcat then have a look at this answer https://stackoverflow.com/a/20194823/2445898
If you are using Glassfish server like i am suing Glassfish 9, you can configure glassfish-web.xml file to do the same.
Create a glassfish-web.xml file in WEB-INF directory of your web application if it does not exists already and add the following lines
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD
GlassFish Application Server 3.1 Servlet 3.0//EN"
"http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<jsp-config>
<property name="compilerSourceVM" value="7"/>
<property name="compilerTargetVM" value="7"/>
</jsp-config>
</glassfish-web-app>
After adding this. Stop and restart your server. It should work now. It worked for me i hope this will work for you too.