/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;

/**
 *
 * @author a.belovol
 */
public class SignatureGenerator extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter pout = response.getWriter()) {
            
            // Установка полученных от пользователя параметров ...
            Sotrudnik aSotrudnik = new Sotrudnik();
            
            String login  = request.getParameter("login");
            aSotrudnik.setLogin(login);
            String fullName  = request.getParameter("fullName");
            aSotrudnik.setFullName(fullName);
            String posada = request.getParameter("posada");
            aSotrudnik.setPosada(posada);
            String city   = request.getParameter("city");
            aSotrudnik.setCity(city);
            String point  = request.getParameter("point");
            aSotrudnik.setPoint(point);
            String pfone  = request.getParameter("pfone");
            aSotrudnik.setPfone(pfone);
            String region = request.getParameter("Region");
            aSotrudnik.setRegion(region);
            
            List listProp = new LinkedList();      
        
            listProp = SignaturePropertyGenerator.updateSignatureProperty(listProp, aSotrudnik);

            Iterator iterator = listProp.iterator();
            while(iterator.hasNext()){
                String element = (String) iterator.next();
                pout.println(element);
            }
            
            File file = new File(login + ".html");
            if (file.exists()) {
//                out.println("file is true");
            }
            else{
                file.createNewFile();
                FileWriter fout = new FileWriter(file);
                Iterator iterator2 = listProp.iterator();
                while(iterator2.hasNext()){
                    String element = (String) iterator2.next();
                    fout.append(element);
                }
                fout.flush();
                fout.close();
            }
                    
//            out.println("Debug:");
//            out.println("<br/>");
//            out.println("Skript planiruetsia pologity v ... ");
//            out.println(region);
//            out.println("<br/>");

            
           /// out.println(property);
                 //out.println("just the text"); 
//                 out.println("try " + login);
                  
//                 out.println("  ");  

        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
//        String login = request.getParameter("login");
        
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}

@@ -2710,37 +2710,211 @@
     
- out.println(%22file is true%22);
+TODO: write add logics%0D%0A//               TODO: %D1%80%D0%B0%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D1%82%D1%8C%D1%81%D1%8F %D0%BA%D0%B0%D0%BA %D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%B0%D0%B5%D1%82 %D0%BF%D1%80%D0%B8 %D0%BD%D0%B0%D0%BB%D0%B8%D1%87%D0%B8%D0%B8 %D1%84%D0%B0%D0%B9%D0%BB%D0%B0%0D%0A//               TODO: %D0%91%D1%83%D0%B4%D0%B5%D1%82 %D0%BE%D1%87%D0%B5%D0%BD%D1%8C %D0%B0%D0%BA%D1%82%D1%83%D0%B0%D0%BB%D1%8C%D0%BD%D0%B8 %D0%BD%D0%B0 %D0%BC%D0%BE%D0%BC%D0%B5%D0%BD%D1%82 %22%D0%BF%D0%B5%D1%80%D0%B5%D0%B7%D0%B0%D0%BF%D0%B8%D1%81%D0%B8 %D0%BF%D0%BE%D0%B4%D0%BF%D0%B8%D1%81%D0%B8 %D0%B8 %D0%BA%D0%BE%D0%BD%D1%84%D0%B8%D0%B3%D0%B0%22%0D%0A                         
 %0D%0A  
@@ -3341,32 +3341,32 @@
 %0A            %7D%0D%0A
+
                 
@@ -3375,441 +3375,8 @@
   %0D%0A
-//            out.println(%22Debug:%22);%0D%0A//            out.println(%22%3Cbr/%3E%22);%0D%0A//            out.println(%22Skript planiruetsia pologity v ... %22);%0D%0A//            out.println(region);%0D%0A//            out.println(%22%3Cbr/%3E%22);%0D%0A%0D%0A            %0D%0A           /// out.println(property);%0D%0A                 //out.println(%22just the text%22); %0D%0A//                 out.println(%22try %22 + login);%0D%0A                  %0D%0A//                 out.println(%22  %22);  %0D%0A%0D%0A
     

Work at Signatures add research task