portfolio/src/main/java/com/google/sps/servlets/DataServlet.java
@Override
  public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    UserService userService = UserServiceFactory.getUserService();

    String comment = request.getParameter("comment");
    String name = request.getParameter("name");
    long timestamp = System.currentTimeMillis();
    String email = userService.getCurrentUser().getEmail();

    Entity commentEntity = new Entity("Comments");
    commentEntity.setProperty("comment", comment);
    commentEntity.setProperty("timestamp", timestamp);
    commentEntity.setProperty("name", name);
    commentEntity.setProperty("email", email);

    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    datastore.put(commentEntity);
    response.sendRedirect("/index.html");
  }
//Receives the user comment and redirect to the homepage.
Receives the user comment and redirect to the homepage.
Receives the user comment and redirect to the homepage .
@Override
  public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    UserService userService = UserServiceFactory.getUserService();
    String comment = request.getParameter("comment");
    String name = request.getParameter("name");
    long timestamp = System.currentTimeMillis();
    String email = userService.getCurrentUser().getEmail();
    Entity commentEntity = new Entity("Comments");
    commentEntity.setProperty("comment", comment);
    commentEntity.setProperty("timestamp", timestamp);
    commentEntity.setProperty("name", name);
    commentEntity.setProperty("email", email);
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    datastore.put(commentEntity);
    response.sendRedirect("/index.html");
  }
@ Override public void doPost ( HttpServletRequest request , HttpServletResponse response ) throws IOException { UserService userService = UserServiceFactory . getUserService ( ) ; String comment = request . getParameter ( "comment" ) ; String name = request . getParameter ( "name" ) ; long timestamp = System . currentTimeMillis ( ) ; String email = userService . getCurrentUser ( ) . getEmail ( ) ; Entity commentEntity = new Entity ( "Comments" ) ; commentEntity . setProperty ( "comment" , comment ) ; commentEntity . setProperty ( "timestamp" , timestamp ) ; commentEntity . setProperty ( "name" , name ) ; commentEntity . setProperty ( "email" , email ) ; DatastoreService datastore = DatastoreServiceFactory . getDatastoreService ( ) ; datastore . put ( commentEntity ) ; response . sendRedirect ( "/index.html" ) ; }
Receives the user comment and redirect to the homepage.
Receives the user comment and redirect to the homepage .