-1

私は3つのjspページ、つまりa.jsp、b.jsp、c.jspを持っています。a.jspには、bとcがロードされるdivがあります。今、私の要件は、b.jspから値を送信する必要があることです。 c.jsp で取得します。何か考えはありますか? 私のコードをチェックしてください

a.jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--DVID=00014EAD-->
<html>
<head>

<title>Tabs in HTML with CSS</title>
<script src="resources/js2/jquery-1.6.2.min.js"></script>
<style type="text/css">
<!--
#tabs {
    border-bottom: .5em solid #0033CC;
    margin: 0;
    padding: 0;
}

#tabs li {
    display: inline;
    border-top: .1em solid #03c;
    border-left: .1em solid #03c;
    border-right: .1em solid #03c;
}

#tabs li a {
    text-decoration: none;
    padding: 0.25em 1em;
    color: #000;
}

#page1 #tabs li#tab1 a,#page2 #tabs li#tab2 a,#page3 #tabs li#tab3 a,.page4 li#tab4 a
    {
    padding: 0.25em 1em;
    background-color: #03c;
    color: #fff;
}
-->
</style>

<script type="text/javascript">

    function profile() {
        var xmlhttp;
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", "b.jsp", true);
        xmlhttp.send();
    }

    function fields() {
        var xmlhttp;
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", "c.jsp", true);
        xmlhttp.send();
    }
</script>
</head>

<body id="page3">
    <ul id="tabs">
        <li id="tab1"><a href="#" onclick="profile()">Tab 1</a></li>
        <li id="tab2"><a href="#">Tab 2</a></li>

    </ul>

    <div id="myDiv"></div>
</body>
</html>

b.jsp

<html>
        <head><title>getQueryString() method of request object.</title></head>
                <body>
                <form method="get">
                        <table border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                        <td>User Name: </td>
                                        <td><input type="text" size="20" name="name" />
                                </tr>

                                <tr>
                                        <td> </td>
                                        <td><input type="button" id="NextBtn" value="Next" >
                                        </td>
                                </tr>
                        </table>
                       <%String name = request.getParameter("name");
                       session.setAttribute("name", name);
                     %>
                </form>

        </body>
</html>

c.jsp

<html>
<body>

<%

out.println("Name : " + (String)session.getAttribute("name") + "<br/>");

%>
</body>
</html>
4

1 に答える 1

0

私が気づいた 2 つの間違いがあります:
b.jsp では、これを修正する必要があります。

<form method="get" action="c.jsp">


c.jsp で、これを修正する必要があります。

<%= (String)session.getAttribute("name") %> <br>


于 2012-07-09T07:48:47.630 に答える