WeatherForecastServlet.java
上传用户:shen332233
上传日期:2021-09-03
资源大小:7478k
文件大小:2k
源码类别:

Ajax

开发平台:

Java

  1. package ajaxdashboard.servlet;
  2. import ajaxdashboard.service.WeatherForecastService;
  3. import java.io.*;
  4. import java.net.*;
  5. import javax.servlet.*;
  6. import javax.servlet.http.*;
  7. public class WeatherForecastServlet extends HttpServlet {
  8.     protected void processRequest(HttpServletRequest request
  9.                                             , HttpServletResponse response)
  10.                                             throws ServletException, IOException {
  11.         
  12.         WeatherForecastService forecastService = new WeatherForecastService();
  13.         request.setAttribute("forecastData", forecastService.getForecastFor("55431"));
  14.         request.getRequestDispatcher("/jsp/ajaxDashboard.jsp").forward(request, response);
  15.     }
  16.     
  17.     // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
  18.     /** Handles the HTTP <code>GET</code> method.
  19.      * @param request servlet request
  20.      * @param response servlet response
  21.      */
  22.     protected void doGet(HttpServletRequest request, HttpServletResponse response)
  23.     throws ServletException, IOException {
  24.         processRequest(request, response);
  25.     }
  26.     
  27.     /** Handles the HTTP <code>POST</code> method.
  28.      * @param request servlet request
  29.      * @param response servlet response
  30.      */
  31.     protected void doPost(HttpServletRequest request, HttpServletResponse response)
  32.     throws ServletException, IOException {
  33.         processRequest(request, response);
  34.     }
  35.     
  36.     /** Returns a short description of the servlet.
  37.      */
  38.     public String getServletInfo() {
  39.         return "Short description";
  40.     }
  41.     // </editor-fold>
  42. }