Vyacheslav Sermyazhko
Vyacheslav Sermyazhko

Reputation: 359

Making HTML element visible/invisible depending on HttpServletRequest parameter

I have a jsp page, which imports another jsp. This import is wrapped into div tag. Also I have parameter with values "true/false", which arrives from servlet as a request parameter. I wonder what's the way to change mentioned visibility(with the help of "style.display" attribute) using the request parameter value. The div should be visible/invisible immediately after page loads. Any ideas? Thanks in advance.

Upvotes: 2

Views: 2960

Answers (2)

Muhammed Nigil
Muhammed Nigil

Reputation: 183

you can use

<%
    if("true".equalsIgnoreCase((String)request.getAttribute("true"))){
%>
    <div class="message_div">
        // div given for style .. if div is not there too its fyn   
        //import jsp here
   </div>
<%  
   }    
%>

Upvotes: 2

jddsantaella
jddsantaella

Reputation: 3687

If you don't want to display a JSP fragment (it can be a fragment that import another JSP) I would avoid to use "style.display attribute and I would do this:

<c:if test="${myVariable}">
     // import jsp, whatever you want
</c:if>

This is better that to import the jsp and them hide it.

Upvotes: 5

Related Questions