In my .jsp file I have the code below. How can I compare the environment variable to a string? Netbeans isn’t liking this… I’ve tried adding scope="request" to the c:set with no luck.
<c:set var="environment" value="<%=(request.getRequestURL().indexOf("localhost") > 0) ? "dev" : "uat"%>"/>
<% if (environment.equals("live")) { %>
Is there any particular reason that you wouldn’t do this entirely in scriptlet? You can still access the variable in JSTL if it was defined in scriptlet
Have a look here:
http://melandri.net/2009/09/16/scriptlet-and-jstl-variable-sharing/
You could also do it entirely in JSTL to: