sergAccount

Untitled

Feb 22nd, 2021
663
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.spec.servlet;
  7.  
  8. import java.io.IOException;
  9. import java.io.PrintWriter;
  10. import javax.servlet.ServletException;
  11. import javax.servlet.annotation.WebServlet;
  12. import javax.servlet.http.HttpServlet;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15.  
  16. /**
  17.  *
  18.  * @author Admin
  19.  */
  20. @WebServlet(name = "FServlet", urlPatterns = {"/FServlet"})
  21. public class FServlet extends HttpServlet {
  22.  
  23.     /**
  24.      * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
  25.      * methods.
  26.      *
  27.      * @param request servlet request
  28.      * @param response servlet response
  29.      * @throws ServletException if a servlet-specific error occurs
  30.      * @throws IOException if an I/O error occurs
  31.      */
  32.     protected void processRequest(HttpServletRequest request, HttpServletResponse response)
  33.             throws ServletException, IOException {      
  34.         String id = request.getParameter("id");
  35.         System.out.println("FServlet.id=" + id);
  36.           // forward  запроса (перенаправление) - используем метод forward
  37.         request.getRequestDispatcher("/result.jsp").forward(request, response);      
  38.     }
  39.  
  40.     // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
  41.     /**
  42.      * Handles the HTTP <code>GET</code> method.
  43.      *
  44.      * @param request servlet request
  45.      * @param response servlet response
  46.      * @throws ServletException if a servlet-specific error occurs
  47.      * @throws IOException if an I/O error occurs
  48.      */
  49.     @Override
  50.     protected void doGet(HttpServletRequest request, HttpServletResponse response)
  51.             throws ServletException, IOException {
  52.         processRequest(request, response);
  53.     }
  54.  
  55.     /**
  56.      * Handles the HTTP <code>POST</code> method.
  57.      *
  58.      * @param request servlet request
  59.      * @param response servlet response
  60.      * @throws ServletException if a servlet-specific error occurs
  61.      * @throws IOException if an I/O error occurs
  62.      */
  63.     @Override
  64.     protected void doPost(HttpServletRequest request, HttpServletResponse response)
  65.             throws ServletException, IOException {
  66.         processRequest(request, response);
  67.     }
  68.  
  69.     /**
  70.      * Returns a short description of the servlet.
  71.      *
  72.      * @return a String containing servlet description
  73.      */
  74.     @Override
  75.     public String getServletInfo() {
  76.         return "Short description";
  77.     }// </editor-fold>
  78.  
  79. }
  80.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×