Search in sources :

Example 1 with GetContentParameter

use of io.clownfish.clownfish.datamodels.GetContentParameter in project Clownfish by rawdog71.

the class GetContentCountHibernate method doPost.

/**
 * 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 {
    StringBuffer jb = new StringBuffer();
    String line = null;
    try {
        BufferedReader reader = request.getReader();
        while ((line = reader.readLine()) != null) {
            jb.append(line);
        }
    } catch (Exception e) {
    /*report an error*/
    }
    Gson gson = new Gson();
    GetContentParameter gcp = gson.fromJson(jb.toString(), GetContentParameter.class);
    processRequest(gcp, response);
    String json = gson.toJson(gcp);
    response.setCharacterEncoding("UTF-8");
    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    out.println(json);
    out.flush();
}
Also used : GetContentParameter(io.clownfish.clownfish.datamodels.GetContentParameter) BufferedReader(java.io.BufferedReader) Gson(com.google.gson.Gson) ServletException(javax.servlet.ServletException) NoResultException(javax.persistence.NoResultException) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 2 with GetContentParameter

use of io.clownfish.clownfish.datamodels.GetContentParameter in project Clownfish by rawdog71.

the class GetContentHibernate method doPost.

/**
 * 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 {
    StringBuffer jb = new StringBuffer();
    String line = null;
    try {
        BufferedReader reader = request.getReader();
        while ((line = reader.readLine()) != null) {
            jb.append(line);
        }
    } catch (IOException e) {
    /*report an error*/
    }
    Gson gson = new Gson();
    GetContentParameter gcp = gson.fromJson(jb.toString(), GetContentParameter.class);
    processRequest(gcp, response);
    String json = gson.toJson(gcp);
    response.setCharacterEncoding("UTF-8");
    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    out.println(json);
    out.flush();
}
Also used : GetContentParameter(io.clownfish.clownfish.datamodels.GetContentParameter) BufferedReader(java.io.BufferedReader) Gson(com.google.gson.Gson) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 3 with GetContentParameter

use of io.clownfish.clownfish.datamodels.GetContentParameter in project Clownfish by rawdog71.

the class GetDatalist method doPost.

/**
 * 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 {
    StringBuffer jb = new StringBuffer();
    String line = null;
    try {
        BufferedReader reader = request.getReader();
        while ((line = reader.readLine()) != null) {
            jb.append(line);
        }
    } catch (IOException e) {
    /*report an error*/
    }
    Gson gson = new Gson();
    GetContentParameter gcp = gson.fromJson(jb.toString(), GetContentParameter.class);
    if (null != gcp) {
        processRequest(gcp, response);
    }
    String json = gson.toJson(gcp);
    response.setContentType("application/json;charset=UTF-8");
    response.setCharacterEncoding("UTF-8");
    PrintWriter out = response.getWriter();
    out.println(json);
    out.flush();
}
Also used : GetContentParameter(io.clownfish.clownfish.datamodels.GetContentParameter) BufferedReader(java.io.BufferedReader) Gson(com.google.gson.Gson) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 4 with GetContentParameter

use of io.clownfish.clownfish.datamodels.GetContentParameter in project Clownfish by rawdog71.

the class GetDatalistHibernate method doPost.

/**
 * 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 {
    StringBuffer jb = new StringBuffer();
    String line = null;
    try {
        BufferedReader reader = request.getReader();
        while ((line = reader.readLine()) != null) {
            jb.append(line);
        }
    } catch (IOException e) {
    /*report an error*/
    }
    Gson gson = new Gson();
    GetContentParameter gcp = gson.fromJson(jb.toString(), GetContentParameter.class);
    processRequest(gcp, response);
    String json = gson.toJson(gcp);
    response.setContentType("application/json;charset=UTF-8");
    response.setCharacterEncoding("UTF-8");
    PrintWriter out = response.getWriter();
    out.println(json);
    out.flush();
}
Also used : GetContentParameter(io.clownfish.clownfish.datamodels.GetContentParameter) BufferedReader(java.io.BufferedReader) Gson(com.google.gson.Gson) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 5 with GetContentParameter

use of io.clownfish.clownfish.datamodels.GetContentParameter in project Clownfish by rawdog71.

the class GetContent method doPost.

/**
 * 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 {
    StringBuffer jb = new StringBuffer();
    String line = null;
    try {
        BufferedReader reader = request.getReader();
        while ((line = reader.readLine()) != null) {
            jb.append(line);
        }
    } catch (Exception e) {
    /*report an error*/
    }
    Gson gson = new Gson();
    GetContentParameter gcp = gson.fromJson(jb.toString(), GetContentParameter.class);
    processRequest(gcp, response);
    String json = gson.toJson(gcp);
    response.setCharacterEncoding("UTF-8");
    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    out.println(json);
    out.flush();
}
Also used : GetContentParameter(io.clownfish.clownfish.datamodels.GetContentParameter) BufferedReader(java.io.BufferedReader) Gson(com.google.gson.Gson) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Aggregations

Gson (com.google.gson.Gson)5 GetContentParameter (io.clownfish.clownfish.datamodels.GetContentParameter)5 BufferedReader (java.io.BufferedReader)5 IOException (java.io.IOException)5 PrintWriter (java.io.PrintWriter)5 ServletException (javax.servlet.ServletException)2 NoResultException (javax.persistence.NoResultException)1