jsp+servlet之内置对象
2016-06-08 09:23
405 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u010219315/article/details/51610832
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <form action="<%=basePath%>/servlet/DemoReuestServlet" method="post"> 姓名<input name="name"><br> 密码<input type="password" name="pwd"><br> <input type="submit" value="提交"> </form> </body> </html>
package com.pb.web; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class DemoReuestServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); //post方式编码 request.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); String name = request.getParameter("name"); String pwd = request.getParameter("pwd"); out.print("用户名:"+name); out.print("<br/>"); out.print("密码:"+pwd); out.flush(); out.close(); } }
相关文章推荐
- xstream在 xml、json和bean之…
- Js中的window.parent ,window…
- [收藏]javascript keycode大全
- 几种常用的json序列化和反序列化工具介绍
- html解析利器-JSOUP
- Javascript判断日文全角半角长度
- Javascript中switch case的一个细节
- js 中使用el表达式 关键总结:在js中使用el表达式一定要使用双引号
- 针对js中li标签的获取
- javascript编写方式及基本类型,引用类型
- js(javascript)小谈变量声明(显隐声明,声明提前)
- 淘宝手机屏幕尺寸判断改变字体大小的js:
- Json.net 常用使用小结(推荐)
- 遍历json对象的属性和值,并循环动态定义声明变量
- javascript div跟随鼠标移动
- javascript点击之后使元素e左右震动
- javascript 模块点击抖动之后变为透明
- UnderscoreJS
- javascript中内存泄露问题的解决方案
- js 迷你库