How can I check if a given query parameter is present using Struts tags?

Some pages may receive a specific request parameter called "P1":

page.do?P1=value1 

The scriptlet is currently checking for the existence of the query parameter, and if P1 is "value1", some information is displayed on the page.

Instead of using a script, I want to rewrite this with Struts tags.

Could you give me some tips on what to use?

An alternative scriptlet looks something like this:

 <% String p1 = request.getParameter("P1"); if ("value1".equals(p1)) { //do something } %> 
+6
java-ee struts taglib
source share
2 answers

I believe you need something like this. This is a standard taglib and a better idea than struts tags.

 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <c:if test="${not empty param.P1}"> hello there </c:if> 
+11
source share

try it -

 <c:if test="${not empty requestScope.P1}" > 

it would work for me.

+1
source share

All Articles