jsp页面提交到servlet实例

jsp文件名jsp2.jsp

<%@ page contentType="text/html; charset=GBK" %>


<br>jsp2<br>



JBuilder Generated JSP











servlet
文件名 xianluserch.java
package web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class XianLuSerch extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html; charset=GBK";

    //Initialize global variables
    public void init() throws ServletException {
    }

    //Process the HTTP Get request
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        response.setContentType(CONTENT_TYPE);
        String ss=request.getParameter("tt");
        PrintWriter out = response.getWriter();
        out.println("");
        out.println("XianLuSerch");
        out.println("");
        out.println("

The servlet has received a " + request.getMethod() +"ss"+
                    ". This is the reply.

");
        out.println("");
        out.println("");
        out.close();
        System.out.println("sddddddddddddddddddddddddddddddddddddddd");
    }

    //Process the HTTP Post request
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        response.setContentType(CONTENT_TYPE);
        doGet(request, response);
    }

    //Clean up resources
    public void destroy() {
    }
}

web.xml



  Web


 
    xianluserch
    web.XianLuSerch
 

 
    xianluserch
    /xianluserch
 

 
    Added by JBuilder to compile JSPs with debug info
    debugjsp
    org.apache.jasper.servlet.JspServlet
   
      classdebuginfo
      true
   

    3
 

 
    debugjsp
    *.jsp
 


 
本篇文章来源于:http://edu.codepub.com/2009/0630/7600.php

你可能感兴趣的:(java,Servlet,JSP,JBuilder,Web,XML)