在JSP中弹出显示数据

时间:2015-06-26 13:04:07

标签: javascript java html jsp servlets

我是一名使用网络应用程序的新手。我有一个列表,显示在我使用servlet完成的JSP中。它要在同一个浏览器页面上显示时才能正常工作。现在我想在弹出窗口中显示相同内容?我该怎么做。我尝试过使用window.open,但没有用。它会引发404错误。请找到以下代码。非常感谢。

的index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="servlet/Controller">  
Enter your Id:<input type="text" name="City"/><br/>  
<a href="javascript:child_open()">Click me</a>
<script type="text/javascript">
var popupWindow=null;
function child_open()
{ 
popupWindow =window.open('display.jsp',"_blank","directories=no, status=no, menubar=no, scrollbars=yes, resizable=no,width=600, height=280,top=200,left=200");
}

</script>

<input type="submit" value="search"  onclick="child_open()"/>  
</form>
</body>
</html>

Display.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!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>Insert title here</title>
</head>
<body>


<div align="center">

     <table border="1" >

                    <h2>List of users</h2></caption>
            <tr>
                <th>ADDRESS_ID</th>
                <th>ADDRESS_LINE1</th>
                <th>ADDRESS_LINE2</th>
                <th>ADDRESS_LINE3</th>
                <th>CITY</th>
                <th>COUNTRY_CD</th>
                <th>ZIP</th>
                <th>UPDATER</th>
                <th>TIME_STAMP</th>
            </tr>
            <c:forEach var="user" items="${Data}">
                <tr>
                    <td><c:out value="${user.addressId} " /></td>
                    <td><c:out value="${user.addressLine1}" /></td>
                    <td><c:out value="${user.addressLine2}" /></td>
                    <td><c:out value="${user.addressLine3}" /></td>
                    <td><c:out value="${user.cityCd}" /></td>
                    <td><c:out value="${user.countryCd}" /></td>
                    <td><c:out value="${user.zip}" /></td>
                    <td><c:out value="${user.updater}" /></td>
                    <td><c:out value="${user.timeStamp}" /></td>

                </tr>
            </c:forEach>
        </table>
    </div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

这可以通过使用Ajax调用来实现..请参考以下链接,它可能对您有帮助......

http://www.hiteshagrawal.com/ajax/ajax-programming-with-jsp-and-servlets/

相关问题