package servlet;

import com.jscape.inet.ssh.SshException;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.*;
import javax.servlet.http.*;
import ssh.*;

public class TesztServlet extends HttpServlet {
   

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        try {
            SshConnect ssh = (SshConnect) request.getSession().getAttribute("ssh");            
            /*request.getSession().setAttribute("valasz", ssh.Teszt(request.getParameter("feladat_szam")));
            System.out.println(ssh.session.send("cd /home/"+request.getSession().getAttribute("username")));
            String nextJSP = "/tesztMessage.jsp";
            RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
            dispatcher.forward(request,response);  */
            
            PrintWriter out = response.getWriter();
            response.setContentType("text/plain;charset=UTF-8");
            try{
                out.println(ssh.Teszt(request.getParameter("feladat_szam")));
                System.out.println(ssh.session.send("cd /home/"+request.getSession().getAttribute("username")));
            }finally{
                out.close();
            }
        } catch (SshException ex) {
            System.out.println(ex);
        }
    }

}
