/*
 * 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.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 out = 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();
                out.println(element);
            }
            
//            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>

}

@@ -504,32 +504,60 @@
 oundException;%0D%0A
+import java.io.FileWriter;%0D%0A
 import java.util
@@ -1300,16 +1300,17 @@
 tWriter 
+p
 out = re
@@ -2542,32 +2542,33 @@
                 
+p
 out.println(elem
@@ -2595,32 +2595,626 @@
 %0D%0A            %0D%0A
+            File file = new File(login + %22.html%22);%0D%0A            if (file.exists()) %7B%0D%0A//                out.println(%22file is true%22);%0D%0A            %7D%0D%0A            else%7B%0D%0A                file.createNewFile();%0D%0A                FileWriter fout = new FileWriter(file);%0D%0A                Iterator iterator2 = listProp.iterator();%0D%0A                while(iterator2.hasNext())%7B%0D%0A                    String element = (String) iterator2.next();%0D%0A                    fout.append(element);%0D%0A                %7D%0D%0A                fout.flush();%0D%0A                fout.close();%0D%0A            %7D%0D%0A                    %0D%0A
 //            ou

Work at Signatures Write signature to file