您现在的位置 科汛网络开发 > 站长充电站 > jsp教程 > jsp基础 > 浏览文章

Jsp&Servelet 学习笔记1(2)
来源:不详 作者:佚名 更新时间: 2009年07月02日 点击:
         out.println("Your last name: "); 
         out.println(""); 
         out.println(""); 
         out.println("Your email: "); 
         out.println(""); 
         out.println(""); 
         out.println(""); 
         out.println("");    out.println("");   
   }
//doGet
    public void doPost(HttpServletRequest request,     HttpServletResponse response) throws ServletException,    java.io.IOException   ...{    
    //display the parameter names and values 
        Enumeration paramNames = request.getParameterNames( );  
        String parName;
       //this will hold the name of the parameter   
         boolean emptyEnum = false; 
        if (! paramNames.hasMoreElements( ))  
        emptyEnum = true;      
           //set the MIME type of the response, "text/html" 
        response.setContentType("text/html");    
         //use a PrintWriter to send text data to the client 
        java.io.PrintWriter out = response.getWriter( );    
         //Begin assembling the HTML content 
        out.println(""); 
        out.println("Submitted Parameters");   
          if (emptyEnum)  ...{  
                out.println(           "

Sorry, the request does not contain any parameters

");
          } else   ...{  
                        out.println(        "

Here are the submitted parameter values

");  
          }    
          while(paramNames.hasMoreElements( ))  ...{     
                  parName = (String) paramNames.nextElement( );    
                  out.println(            "" + parName + " : " +                request.getParameter(parName));   
                 out.println("
");  
          }//while     
         out.println("");  
         }
 // doPost
 }
 
你有可能注意到doGet()和doPost()每个将抛出ServletException和IOException.那是因为response.getWriter()将会抛出IO异常。
 
http://blog.csdn.net/bruceleey/archive/2007/02/07/1503843.aspx

关于我们 | 联系方式 | 增值服务 | 授权相关 | 相关说明