I need to create a special condition if the page URL in the browser address bar ends in "search". In my .jpsf file, I have this code so far:
<c:choose>
<c:when test="${SOMETHINGHERE eq 'Search'}">
<c:out value="Search" />
</c:when>
<c:otherwise>
<c:out value="${topCat}" />|<c:out value="${subCatA}" />|<c:out value="${subCatB}" />|<c:out value="${subCatC}" />
</c:otherwise>
</c:choose>
What can I put in the SOMETHINGHERE
section to detect if the URL contains the word search? Browsing the posts here and searching on Google has not led me to any answers that work so far.
I also tried adding <% String currentPDP = request.getParameter("search")%>
but it returned a 500 error, probably because _Search is not set up properly as a parameter (it's hard coded at the end of a URL) and the code is not properly formatted.
I am new to JSP and have to learn on the job, so I appreciate your patience and any help you can offer. Thank you kindly.
First you'd want to import the Functions tag with:
Then, you can use:
or, if you don't care about the case
That will allow you to search through the URI for the term
Search
.If the full url to the running script was
http://www.example.com/site/search.jsp
, thenresponseURL
should return/site/search.jsp
. The above examples would return true in the second case because 'Search' is in the URI string (the first would fail due to capitalization).It does not include query parameters, which would involve a different check.