How can I test if a given request parameter is present using Struts tags?
Asked Answered
S

2

7

Some pages can receive a certain request parameter called "P1":

page.do?P1=value1

Right now a scriptlet is testing the existence of the request parameter, and if P1 is "value1" some information is rendered on the page .

Instead of using a scriptlet I want to rewrite this using Struts tags .

Can you please give me some hints on what to use ?

The alternative scriptlet is something like this:

<%
String p1 = request.getParameter("P1");
if ("value1".equals(p1)) {
//do something
}
%>
Symphonist answered 14/1, 2011 at 11:32 Comment(0)
R
12

I believe that you should something like this. This is standard taglib and it is 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>
Ramachandra answered 14/1, 2011 at 17:42 Comment(0)
J
1

try this-

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

it would work for me.

Jdavie answered 7/11, 2013 at 9:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.