从JSP中的out.print()语句中以表单形式输出输出

时间:2016-11-19 05:56:40

标签: html css jsp

我在Apache Server上运行我的程序。 截至目前,我评论第二种形式,以将输出作为普通文本。

但我想使用第二种形式作为输出表。

使用out.print()

时,我需要JSP文件中的帮助

如何将out.print()的输出传递给第二种形式?

交换两个数字

LAB11.html

<!DOCTYPE html>
    <html>
    <head>
        <title>LAB11</title>
        <style type="text/css">
            div {
            background-color: white;
            width: 20%;
            text-align: center;
            padding: 20px;  
            margin: auto;
            box-shadow: 10px 10px 5px #888888;
            border-radius: 15px;
        }

        input[type=text] {
        padding:5px; 
        border:2px solid #ccc; 
        -webkit-border-radius: 5px;
        border-radius: 5px;
        }

        input[type=text]:focus {
        border-color:#333;
        }

        input[type=submit] {
        padding:5px 15px; 
        background:#ccc; 
        border:0 none;
        cursor:pointer;
        -webkit-border-radius: 5px;
        border-radius: 5px; 
        }

        </style>
    </head>

    <body bgcolor="BlanchedAlmond">
    <h1 style="text-align: center;font-size: 30px;color:crimson">Swapping of two numbers</h1>
    <div>
    <form action="LAB11_1.jsp">
    <table>
        <tr>
            <td>First Number:</td>
            <td><input type="text" name="n1"></td><br>
        </tr>

        <tr>
            <td>Second Number:</td>
            <td><input type="text" name="n2"></td>
        </tr>

        <tr>
            <td></td>
            <td><input type="submit" value="Swap"></td>
        </tr>
    </table>
    </form>
    </div>

    <h1 style="text-align: center;font-size: 30px;color:crimson">After Swapping</h1>
    <div>
    <form>
    <table>
        <tr>
            <td>First Number:</td>
            <td><input type="text" name="n3" id="n3"></td><br>
        </tr>

        <tr>
            <td>Second Number:</td>
            <td><input type="text" name="n4" id="n4"></td>
        </tr>
    </table>
    </form>
    </div>ss

    </body>
    </html>

LAB11_1.jsp

<!DOCTYPE html>
<html> 
<head>
    <title>LAB11_1</title>
</head>
<body> 

<%
int a=Integer.parseInt(request.getParameter("n1"));
int b=Integer.parseInt(request.getParameter("n2"));

    a=a+b;
    b=a-b;
    a=a-b;

    out.print(a+"<br>");
    out.print(b+"<br>");
%> 
</body> 
</html>

0 个答案:

没有答案