首页 > Web开发 > 详细

servlet跳转jsp

时间:2016-05-05 22:34:56      阅读:322      评论:0      收藏:0      [点我收藏+]

ackage com.monkey.servlet;

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

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

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

    //Process the HTTP Get request
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        RequestDispatcher rd = request.getRequestDispatcher("hello.jsp");
        String name = "tom";
        request.setAttribute("id",name);//存值
        rd.forward(request,response);
    }

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

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

servlet跳转jsp

原文:http://www.cnblogs.com/20000ding/p/5463266.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!