@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();

        if (init == false) {
            try {
                username = request.getParameter("name");
                server = (ChatServer) Naming.lookup("ChatServer");
                handle = new ClientProxyImpl(this);
                session = server.subscribeUser(username, handle);
            } catch (NotBoundException ex) {
                Logger.getLogger(ChatServlet.class.getName()).log(Level.SEVERE, null, ex);
            } catch (MalformedURLException ex) {
                Logger.getLogger(ChatServlet.class.getName()).log(Level.SEVERE, null, ex);
            } catch (RemoteException ex) {
                Logger.getLogger(ChatServlet.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                init = true;
            }
        }

        try {
            /* TODO output your page here. You may use following sample code. */
            out.println("<!DOCTYPE html>");
            out.println("<html>\n"
                    + "    <head>\n"
                    + "        <title></title>\n"
                    + "        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n"
                    + "    </head>\n"
                    + "    <body>\n"
                    + "     <p>Sie sind angemeldet als: " + username + "</p>\n"
                    + "        <form name=\"form2\" method=\"post\">\n"
                    + "            <input type=\"text\" name=\"eingabe\"><br>\n"
                    + "            <input type=\"submit\" name=\"go\" value=\"Abschicken\"><br>\n"
                    + "            <textarea name=\"ausgabe\" cols=\"50\" rows=\"10\" readonly>" + messages + "</textarea><br>\n"
                    + "            <input type=\"button\" name=\"beenden\" value=\"Beenden\" onclick=\"beenden();\"><br>\n"
                    + "        </form>\n"
                    + "    </body>\n"
                    + "</html>");
        } finally {
            out.close();
        }
        String eingabe = request.getParameter("eingabe");;
        if (eingabe != null && eingabe.trim().length() > 0) {
            sendMessage(eingabe);
        }
    }