The application is made using Struts 1.2 framework. I want to get the request header hostname in the jsp file and identify the browser reading the user-agent value from the header.
Below is the code I wrote using scriptlets:
String userAgent = request.getHeader("user-Agent");
if(userAgent.contains("Chrome")){
userAgent = "Chrome";
}else if(userAgent.contains("Android")){
userAgent = "Android";
}
And the code is working fine. But I want to avoid using the scriptlets because it has some vulnerable cross-site scripting issues. Hence for doing the same in EL, I am able to get the header using this:
Host is: ${header["user-agent"]}
But I am not sure how to do the contains check in EL.
This application is running on Struts 1.2 Framework, if the framework provides some better way to read the header value in JSP then also please let me know about it. Otherwise EL is also fine.
You need to use
fn:containsorfn:containsIgnoreCaseAnd then: