简体   繁体   中英

hide div tag in jsp page

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome</title>
<script type="text/javascript">
$(document).ready(function()
        {
            if()==null)
            {

            }
        }
);
</script>
</head>

<center>
    <%@ include file="Head.jsp" %>
</center>
<body>
<div id="tempDiv">
    <h1>Message : ${message}</h1>   
    <h1>Author : ${author}</h1>
</div>  
    <a href='<c:url value="/j_spring_security_logout" />' > Logout</a>
    <div align="center">
        <table class="table1">
            <tr>
                <td align="center" width="800" height="400"><font size="10">
                        Welcome </font></td>
            </tr>
        </table>

    </div>
</body>
</html>

How to hide div tag when $message value not come. i want to hide my div tag. in jsp page. when user click on home page. i tried here javascript code but did not get any answer to how to user jsp element in javascript. or any code which usefull to hide div tag in my case do suggest. thank u....

Try this

<c:if test="${empty message}">

</c:if>
<c:if test="${not empty message}">
<div id="tempDiv">
    <h1>Message : ${message}</h1>   
    <h1>Author : ${author}</h1>
</div>  
</c:if>

You need to check if the variable is empty and depending on that print out on the html page...hope it works

or another way

<c:choose>
    <c:when test="${empty message}">

    </c:when>
    <c:otherwise>
    <div id="tempDiv">
        <h1>Message : ${message}</h1>   
        <h1>Author : ${author}</h1>
    </div>  
    </c:otherwise>
</c:choose>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM