<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    如何學好java

    如何學好java,其實很簡單,只要用心體會,慢慢積累!
    posts - 106, comments - 7, trackbacks - 0, articles - 3
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    寫一個最簡單的Servlet

    Posted on 2011-04-29 15:11 哈希 閱讀(259) 評論(0)  編輯  收藏 所屬分類: Servlet 總結
    Web.xml
    二話不說看代碼:
      
     
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" 
        xmlns
    ="http://java.sun.com/xml/ns/j2ee" 
        xmlns:xsi
    ="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation
    ="http://java.sun.com/xml/ns/j2ee 
        http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      <servlet>
        
    <description>This is the description of my J2EE component</description>
        
    <display-name>This is the display name of my J2EE component</display-name>
        
    <servlet-name>ValidateView</servlet-name>
        
    <servlet-class>org.man.prj.ValidateView</servlet-class>
      
    </servlet>

      
    <servlet-mapping>
        
    <servlet-name>ValidateView</servlet-name>
        
    <url-pattern>/ValidateView</url-pattern>
      
    </servlet-mapping>
      
    <welcome-file-list>
        
    <welcome-file>index.jsp</welcome-file>
      
    </welcome-file-list>
    </web-app>

    package org.man.prj;

    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 ValidateView extends HttpServlet {

        
    /**
         * The doGet method of the servlet. <br>
         *
         * 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 {

            doPost(request, response);
        }

        
    /**
         * The doPost method of the servlet. <br>
         *
         * 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 {

            response.setContentType(
    "text/html");
            PrintWriter out 
    = response.getWriter();
            out.println(
    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
            out.println("<HTML>");
            out.println(
    "  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
            out.println(
    "  <BODY>");
            out.print(
    "    This is ");
            out.print(
    this.getClass());
            out.println(
    ", using the POST method");
            out.println(
    "  </BODY>");
            out.println(
    "</HTML>");
            out.flush();
            out.close();
        }

    }
    輸入tomcat驗證一下:
    http://localhost:8888/Validate/ValidateView



    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲精品美女在线观看| 美女黄网站人色视频免费国产| 日本黄页网站免费| 色在线亚洲视频www| 四虎成人精品永久免费AV| 亚洲精品偷拍视频免费观看| 亚洲风情亚Aⅴ在线发布| 成人毛片免费视频| 亚洲mv国产精品mv日本mv| 一级毛片成人免费看免费不卡| 亚洲熟妇av一区二区三区漫画| 国产精品极品美女自在线观看免费| 亚洲高清无码专区视频| 曰韩无码AV片免费播放不卡 | 亚洲日韩乱码久久久久久| 最近中文字幕大全免费视频| 亚洲精品中文字幕无乱码| 思思re热免费精品视频66 | 亚洲色偷偷综合亚洲AV伊人蜜桃| 一区二区三区福利视频免费观看| 亚洲天堂在线播放| 免费无码精品黄AV电影| 精品国产日韩亚洲一区在线| 亚洲日本中文字幕天堂网| 免费a级毛片无码a∨免费软件| 97亚洲熟妇自偷自拍另类图片| 亚洲精品视频免费看| 亚洲字幕AV一区二区三区四区| 国产91久久久久久久免费| 国产乱妇高清无乱码免费| 亚洲欧洲日产国产综合网| 免费毛片在线看片免费丝瓜视频| 黄页网站在线视频免费| 亚洲AV永久无码精品一百度影院| 国产在线观看免费观看不卡| 亚洲乱码在线播放| 在线观看的免费网站无遮挡| 亚洲色大成网站www| 久久激情亚洲精品无码?V| 97视频免费观看2区| 亚洲av无码片vr一区二区三区|