Package Servlet

Source Code of Servlet.GameRating

package Servlet;

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

import DAO.JDBCGameDAO;
import Interface.GameDAOInterface;
import beans.User;

/**
* Servlet implementation class myservlet
*/
public class GameRating extends HttpServlet {
  private static final long serialVersionUID = 1L;
      
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GameRating() {
        super();
        // TODO Auto-generated constructor stub
    }

  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  }

  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    System.out.println(request.getParameter("num"));
    System.out.println(request.getParameter("rate"));
    User user =(User)request.getSession().getAttribute("user");
    System.out.println(user.getLogin());
   
    GameDAOInterface game = new JDBCGameDAO();
    float rate=0;
    try{
      rate=game.voteForGame(user.getLogin(), Integer.parseInt(request.getParameter("num")), Integer.parseInt(request.getParameter("rate")));
    }catch(Exception e){
      System.out.println(e.getMessage());
    }
    System.out.println(rate);
    String content = ""+rate;
    response.setContentType("text/plain");
    response.setCharacterEncoding("UTF-8");
    response.getWriter().write(content);
  }

}
TOP

Related Classes of Servlet.GameRating

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.