/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.web;

import com.ejb.ConverterLocal;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Administrator
 */
@WebServlet(name = "testConverter", urlPatterns = {"/testConverter"})
public class testConverter extends HttpServlet {

   @EJB
    private ConverterLocal converterBean;
   protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        String s=request.getParameter("param");
        String re=converterBean.toLowerCase(s);
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet TestConverter</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("原来的字符串："+s);
         out.println("<br>");
        out.println("调用EJB商业方法后转换后得到的字符串"+re);
        out.println("</body>");
        out.println("</html>");
        out.close();
    }
   protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }
   protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }
   public String getServletInfo() {
        return "Short description";
    }

}
