Reputation: 2129
I'm trying to detect the name of the page index.jsp
and compare it with the one I need.
<%
String uri = request.getRequestURI();
String pageName = uri.substring(uri.lastIndexOf("/")+1);
if (pageName=="index.jsp"){out.println(pageName); }
out.println(pageName);
%>
It outputs - index.jsp
, but does not do it twice, neither without out.println()
functuion.
Upvotes: 3
Views: 1687
Reputation: 265
String pageName = uri.substring(uri.lastIndexOf("/")+1); if (pageName.equals("index.jsp")){out.println(pageName); }
comparing string values in jsp you have to use .equals("") method
Upvotes: 3