




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
MyEclipse 6 实战开发讲解视频入门 5 MyEclipse 6 + Tomcat 6 Servlet 入门开发2007-10-5视频内容:1. 从 / 下载并安装 Tomcat 6 服务器2. 在 MyEclipse 中配置服务器3. 在 MyEclipse 中启动/停止 Tomcat 64. 新建 Web 项目5. 新建静态页面并添加 GET 和 POST 表单6. 创建 FormServlet7. 编写代码将参数读取出来并输出8. 发布并测试运行, 查看发布内容9. 页面输出汉字内容乱码问题解决 + 如何重新发布10. POST 方式表单参数乱码解决11. GET 方式表单参数乱码解决 下载: /download/MyEclipse6_6.exe 9.37 MB 27分06秒 相关代码:web.xml This is the description of my J2EE component This is the display name of my J2EE component FormServlet servlet.FormServlet FormServlet /FormServlet index.jsp form.html form.html !- GET: POST: FormServlet.javapackage servlet;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 FormServlet extends HttpServlet /* * Constructor of the object. */ public FormServlet() super(); /* * Destruction of the servlet. */ public void destroy() super.destroy(); / Just puts destroy string in log / Put your code here /* * The doGet method of the servlet. * * This method is called when a form has its tag value method equals to get. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException request.setCharacterEncoding(GBK); response.setContentType(text/html;charset=GBK); PrintWriter out = response.getWriter(); out .println(); out.println(); out.println( A Servlet); out.println( ); out.print( 您输入的用户名是:); / GET 方式, 编码转换 String username = request.getParameter(username); username = new String(username.getBytes(ISO8859-1), GBK); out.print(username); out.println(, using the GET method); out.println( ); out.println(); out.flush(); out.close(); /* * The doPost method of the servlet. * * This method is called when a form has its tag value method equals to post. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException / POST 表单参数的乱码解决 request.setCharacterEncoding(GBK); response.setContentType(text/html;charset=GBK); PrintWriter out = response.getWriter(); out .println(); out.println(); out.println( A Servlet); out.println( ); out.print( 您输入的用户名是:); out.print(request.getParameter(username); out.println(, using the POST method); out.println( ); out.println(); out.flush(); out.close(); /*
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024-2025学年八年级语文论文写作教学计划
- 2025年高考全国卷2作文写作指导及范文
- 小学数学翻转课堂研修计划
- 教师学习以案明纪警示教育心得体会
- 幼儿园健康档案管理计划
- 污水处理厂施工技术保障措施
- 石油设备安装质量安全管理措施
- 高速公路质量通病防治措施研究
- 小学语文教研组家长读书指导计划
- 2025下半年幼儿园园长教师激励计划
- 酒类销售用人劳务合同
- 2025老年教育政策环境分析及教学模式创新路径研究报告
- 1-会计信息系统(闭卷)国开机考答案
- 2025年中国伺服电缆行业市场发展前景及发展趋势与投资战略研究报告
- 酒店安全奖惩规定
- 中医养生保健与康复护理
- 夫妻债务隔离约定协议书
- 康复辅助技术咨询师理论考试复习题库(含答案)
- C++冒泡排序实现试题及答案
- NIH-FDA-IND-IDE-II期III期临床试验方案模板
- 西藏参工参建管理制度
评论
0/150
提交评论