2011年11月24日 星期四

JSP m3_lab2

package com.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class m3_lab2
 */
@WebServlet("/m3_lab2")
public class m3_lab2 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public m3_lab2() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws 

ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws 

ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("text/html; charset=big5");
		java.io.PrintWriter out = response.getWriter();
		String [] list = {"大雄","宜靜","技安","阿福"};
		out.println(list[(int)(Math.random()*list.length)].toString());
	}

}

沒有留言:

張貼留言