zoukankan      html  css  js  c++  java
  • JSP 06: 两个内置对象request和response

    内置对象, 不需要创建, 可以直接使用.

    1.  request 对象 (获取从客户端发送过来的数据)

    示例: 从login.jsp页面获取index.jsp发送的用户名和密码:

    <%
      String username = request.getParameter("username");
      String password = request.getParameter("password");
      System.out.println(username + ": " + password);
    %>

    效果:

    2.  response 对象 (向客户端输送数据)

    示例, 在login.jsp中:

    <%

      PrintWriter writer = response.getWriter();
      writer.println("我向客户页面输出了一些数据!");

    %>

    效果:

     

     另外, 通过PrintWriter输出的数据会放在整个网页的最前方:

  • 相关阅读:
    C++中const变量使用注意
    const对象调用static成员函数
    Error in startup script: value for " " missing
    check tcl version
    socket
    grid pack
    mouse bind
    gesture
    pixel
    open
  • 原文地址:https://www.cnblogs.com/JasperZhao/p/13471714.html
Copyright © 2011-2022 走看看