MyEclipse6实战开发讲解入门教程--5 MyEclipse 6 %2B.doc_第1页
MyEclipse6实战开发讲解入门教程--5 MyEclipse 6 %2B.doc_第2页
MyEclipse6实战开发讲解入门教程--5 MyEclipse 6 %2B.doc_第3页
MyEclipse6实战开发讲解入门教程--5 MyEclipse 6 %2B.doc_第4页
MyEclipse6实战开发讲解入门教程--5 MyEclipse 6 %2B.doc_第5页
已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论