在JSP的弹出窗口中显示数据

Display data in popup in JSP

本文关键字:显示 数据 窗口 JSP      更新时间:2023-09-26

我是web应用程序的新手。我有一个列表显示在我的JSP中,这是我使用servlet完成的。当它显示在同一个浏览器页面上时,它可以正常工作。现在我想在弹出窗口中显示相同的内容?。我该怎么做呢?我试过用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>

这可以使用Ajax调用实现。。请参阅下面的链接,它可能会帮助你。。。

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