内置对象(out和request对象)

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 7 <title>Insert title here</title>
 8 </head>
 9 <body>
10 <%
11 //request对象(get方式)附加参数:在URL后面加上?参数名1=参数值1&参数名2=参数值2
12 String name=request.getParameter("name");//接收发来的请求name参数
13 String password=request.getParameter("password");//接收发来的请求password参数
14 out.print("<br>接收的参数name="+name);
15 out.print("<br>接收的参数password="+password+"<br>");
16 //out对象
17 System.out.println("向控制台输出信息");//向控制台输出信息
18 out.print("向浏览器输出信息");//向页面输出信息
19 %>
20 </body>
21 </html>
 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 7 <title>Insert title here</title>
 8 </head>
 9 <body>
10 <%--request对象(post方式) --%>
11 <form action="NewFile2.jsp" method="post"><%--用form表单的方式提交数据参数,规定form表单为method="post"方式--%>
12 名称<input type="text" name="name">
13 密码<input type="password" name="password">
14 <input type="submit" value="提交">
15 </form>
16 </body>
17 </html>

 

posted @ 2016-06-24 22:51  明天会更好!!!!  阅读(231)  评论(0)    收藏  举报