4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
DocumentClonerServlet.java
Go to the documentation of this file.
1 /*
2  * Project: Server for annotations sharing
3  * Author: Ing. Jaroslav Dytrych idytrych@fit.vutbr.cz
4  * File: DocumentClonerServlet.java
5  * Description: Servlet for communication with NLP server (for document clonning)
6  */
7 
8 /**
9  * @file DocumentClonerServlet.java
10  *
11  * @brief Servlet for communication with NLP server (for document clonning)
12  */
13 
14 /**
15  * @package cz.vutbr.fit.knot.annotations.documentCloner
16  *
17  * @brief Classes responsible for cloning document with all annotations
18  */
19 package cz.vutbr.fit.knot.annotations.documentCloner;
20 
22 import java.io.IOException;
23 import java.io.PrintWriter;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
26 import javax.servlet.ServletException;
27 import javax.servlet.http.HttpServlet;
28 import javax.servlet.http.HttpServletRequest;
29 import javax.servlet.http.HttpServletResponse;
30 
31 /**
32  * Servlet for communication with NLP server (for document clonning).
33  *
34  * @brief Servlet for communication with NLP server (for document clonning)
35  * @author Martin Petr (xpetrm05)
36  */
37 public class DocumentClonerServlet extends HttpServlet {
38 
39  /**
40  * Handles the HTTP
41  * <code>GET</code> method.
42  *
43  * @param request servlet request
44  * @param response servlet response
45  * @throws ServletException if a servlet-specific error occurs
46  * @throws IOException if an I/O error occurs
47  */
48  @Override
49  protected void doGet(HttpServletRequest request, HttpServletResponse response)
50  throws ServletException, IOException {
51  PrintWriter out = response.getWriter();
52  try {
54  Logger.getLogger(DocumentClonerServlet.class.getName()).log(Level.ALL, "GET request on DocumentClonerServlet");
55  }
56  } finally {
57  out.close();
58  }
59  }
60 
61  /**
62  * Handles the HTTP
63  * <code>POST</code> method.
64  *
65  * @param request servlet request
66  * @param response servlet response
67  * @throws ServletException if a servlet-specific error occurs
68  * @throws IOException if an I/O error occurs
69  */
70  @Override
71  protected void doPost(HttpServletRequest request, HttpServletResponse response)
72  throws ServletException, IOException {
73 
74  response.setContentType("text/html;charset=UTF-8");
75  PrintWriter out = response.getWriter();
76  try {
77  out.println("OK");
78  } finally {
79  out.close();
80  }
81 
82  DocumentClone documentCloner = new DocumentClone();
83  documentCloner.cloneDocument(request);
84  }
85 
86  /**
87  * Returns a short description of the servlet.
88  *
89  * @return a String containing servlet description
90  */
91  @Override
92  public String getServletInfo() {
93  return "Servlet for communication with NLP server (for document clonning).";
94  }
95 } // public class DocumentClonerServlet
void doPost(HttpServletRequest request, HttpServletResponse response)
Class provides document clonning with new content, iniciated from NLP.
Servlet for communication with NLP server (for document clonning)
void doGet(HttpServletRequest request, HttpServletResponse response)