Community question ยท 3 years ago

Question #290461

JSP -if != null conditions on parameter

I a have jsp form page which get parameters an I need to check if one of them != null ,I have tried to write the condition but its not working: It went to the if block and not to the else block any way(display null or the value respectively).

The code:

</div>
            <div class="grid_8 row12 td_style_fieldValue">
            <% if(!userData7.isEmpty()){%>
            <div id="personalId" class="data_style_payment" disabled="disabled" ><%=userData7%></div>
            <%}else{%>
            <input type="text" pattern="[0-9]*" id="personalId" name="personalId" maxlength="9" dir="ltr" autocomplete="off" onkeyup="limitInput(this,9)" onchange="return validatePersonalId()"/>
            <%}%>
            </div>

"userData7" is a parameter with value. please assist me what am I missing here ?does the if:else syntax is right? tnx

Community responses

0 answers

Add your answer

Share the reasoning, tradeoffs, and code that make your answer useful.