※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

  1. package jp.kylico.HelloWorld;
  2.  
  3. import java.io.IOException;
  4. import java.io.PrintWriter;
  5.  
  6. import javax.servlet.ServletException;
  7. import javax.servlet.annotation.WebServlet;
  8. import javax.servlet.http.HttpServlet;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11.  
  12. /**
  13.  * Servlet implementation class HelloWorld
  14.  */
  15. @WebServlet("/HelloWorld")
  16. public class HelloWorld extends HttpServlet {
  17. private static final long serialVersionUID = 1L;
  18.  
  19. /**
  20.   * @see HttpServlet#HttpServlet()
  21.   */
  22. public HelloWorld() {
  23. super();
  24. // TODO Auto-generated constructor stub
  25. }
  26.  
  27. /**
  28. * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
  29. */
  30. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  31. // TODO Auto-generated method stub
  32.  
  33. response.setContentType("text/html;charset=UTF8");
  34.  
  35. PrintWriter out = response.getWriter();
  36.  
  37. out.println("<HTML>");
  38. out.println("<HEAD>");
  39. out.println("</HEAD>");
  40. out.println("<BODY>");
  41. out.println("HelloWorld<BR>");
  42. out.println("Javaサーブレットにて出力<BR>");
  43. out.println("</BODY>");
  44. out.println("</HTML>");
  45. out.close();
  46. }
  47.  
  48. /**
  49. * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
  50. */
  51. protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  52. // TODO Auto-generated method stub
  53. }
  54.  
  55. }
  56.