/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package web;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author zwergnase
 */
@WebServlet(name="AddNews", urlPatterns={"/AddNews"})
public class AddNews 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");
        PrintWriter out = response.getWriter();
        try{
                       out.println(
                    "<html>"+
                    "<head>"+
                    "<link href=\"design/css/seyirdefteri.css\" type=\"text/css\" rel=\"stylesheet\" />"+
                    "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-9\">"+
                    "</head>"+

                    "<body>"+
                    "<div id=\"genel\">"+

                    "<div id=\"baslik\">"+
                    "<img src=\"design/Pictures/homesmall.jpg\" width=\"70px\" height=\"70px\"/><font id=\"basliktext\"> Haber Ekleme</font>"+
                    "</div>"+

                    "<table id=\"anatablo\">"+
                    "<tr><td>"+
                    "<div id=\"links\">"+
                    "<p>"+
                    "<input type=\"button\" value=\"Haber Ekle\"  id=\"linkbutton\" ONCLICK=\"window.location.href='News'\"/>"+
                    "</p><p>"+
                    "<input type=\"submit\" value=\"Görev Ekle\" id=\"linkbutton\" ONCLICK=\"window.location.href='AddSchedule'\"/>"+
                    "</p><p>"+
                    "<input type=\"button\" value=\"Sorun Giderme\"  id=\"linkbutton\" ONCLICK=\"window.location.href='jsps/KnowledgeDB.jsp'\"/>"+
                    "</p><p>"+
                    "<input type=\"button\" value=\"Kişisel Bilgiler\"  id=\"linkbutton\" ONCLICK=\"window.location.href='findperson'\"  />"+
                    "</p>"+
                    "</div>"+
                    "</td>");

                    out.println("<td> <div id=\"secondcell\">");
                    out.println(
                    "<form id=\"addnewsform\" action=\"insertNews\" method=\"POST\">" +
                    "<table id='news'>"+
                           "<tr>"+
                               "<td id= '1'> Başlık:  </td>"+
                                "<td id='2'> <input type=\"text\" name=\"title\" size=\"30\" /> </td>"+
                         " </tr><tr>"+
                                "<td id='1'>İlgili Kelimeler: </td>"+
                                "<td id='2'><input type=\"text\" name=\"keywords\" size=\"30\" /></td>"+
                          "</tr><tr>"+
                                "<td id='1'>İçerik: </td>"+
                                "<td id='2'><textarea name='description' rows=\"7\" cols=\"34\"></textarea></td>"+
                           "</tr><tr>"+
                               "<td id= '1'> Geçerlilik:  </td>"+
                                "<td id='2'> <input type=\"text\" name=\"valid\" size=\"30\" /> </td>"+
                         " </tr><tr>" +
                           "<td colspan=\"2\" align='right'>"+"<input type=\"submit\" value=\"Gönder\" >"+
                           "</td></tr>"+
                    "</table>"+

                    "<form>"
                            );
                    out.println("</td></tr></table></div></body></html>");






        } finally {
            out.close();
        }
    }

    // <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);
    }

    /**
     * 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>

}
