下载此文档

AndroidHttps服务器端和客户端简单实例.docx


文档分类:IT计算机 | 页数:约11页 举报非法文档有奖
1/11
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/11 下载此文档
文档列表 文档介绍
Android Https服务器端和客户端简单实例
工具介绍

Tomcat (免安装版)
(在Eclipse中配置好)
前提条件
JDK环境要使用我们自己安装的,笔e="text" />vbr /> age:  vinput name="age" type="text" />vbr /> vinput type="submit" value="submit" />&n bsp; &n bsp;&n bsp;&n bsp ;&n bsp;vinput
type="reset" value="reset" />
v/form>
v/body>
v/html>
这里其实是复用了之前Http调研的代码,我们关心的是我们手机端能不能访问 该服务器端,还涉及到传递数据,具体数据显示在TestService表示。
代码如下:
package ;
import ;
import ;
import ;
import ;
import ;
import ;
public class TestService extends HttpServlet {
private static final long serialVersionUID = IL;
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String name = ("name");
String age = ("age"); ("text/html");
PrintWriter out = (); ("vhtml>vhead>vtitle>name&agev/title>v/head"); ("vbody> name:" + name + "<br>");
("age:" + age + "vbrx/bodyx/html>");
("name=" + name);
("age=" + age);
();
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
("utf-8");
String name = ("name");
String age = ("age");
("text/html");
("utf-8");//设置返回给客户端的文本格式,可 解决文字编码不统一的问题
PrintWriter out = ();
("vhtml>vhead>vtitle>name&agev/title>v/head");
("vbody> name:" + name + "<br>");
("age:" + age + "vbrx/bodyx/html>");
("name=" + name);
("age=" + age);
();
}
}
,在倒数第二行加入:
<servlet>
<description>This is the description of my J2EE componentv/description>

AndroidHttps服务器端和客户端简单实例 来自淘豆网www.taodocs.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数11
  • 收藏数0 收藏
  • 顶次数0
  • 上传人niupai11
  • 文件大小74 KB
  • 时间2022-05-20