tw.com.javaworld.CH19.Model2Hello (Java2HTML)

| Model2Hello.java |

    1 package tw.com.javaworld.CH19;
    2
    3 import java.io.*;
    4 import java.util.*;
    5 import javax.servlet.*;
    6 import javax.servlet.http.*;
    7
    8 public class Model2Hello extends HttpServlet {
    9
    10    public void init(ServletConfig config) throws ServletException {
    11        super.init(config);
    12    }
    13
    14    public void service(HttpServletRequest request, HttpServletResponse response)
    15        throws ServletException, IOException {
    16
    17        response.setContentType("text/html");
    18        String Message = "Hello World";
    19        String jsp = "/CH19/Model2Hello.jsp";
    20        request.setAttribute("message", Message);
    21
    22        RequestDispatcher rd = getServletContext().getRequestDispatcher(jsp);
    23        rd.forward(request, response);
    24    }
    25
    26    public void destroy() {
    27    }
    28}