package com.google.sps.servlets;

import com.google.sps.data.VolunteeringOpportunity;
import com.google.sps.utilities.CommonUtils;
import com.google.sps.utilities.SpannerTasks;
import java.io.IOException;
import java.util.Set;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/** Servlet that handles submission of the form for creating volunteering opportunities. */
@WebServlet("/opportunity-signup-form-handler")
public class OpportunitySignupFormHandler extends HttpServlet {
  /**
   * Inserts volunteering opportunity with parameter values for attributes into the database if
   * opportunity ID is not given as a request parameter and updates volunteering opportunity with
   * the opportunity ID if given as a request parameter.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws IOException if Input/Output error occurs
   */
  @Override
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String opportunityId = CommonUtils.getParameter(request, OPPORTUNITY_ID, /* DefaultValue= */ "");
    String email = CommonUtils.getParameter(request, UserServiceFactory.getUserService().getCurrentUser().getEmail(), /* DefaultValue= */ "");

    OpportunitySignup signup =
        new OpportunitySignup.Builder(opportunityId, email).build();
    insertOpportunitySignup(signup);

    response.sendRedirect("/events-feed.html");
  }
}
@@ -49,40 +49,144 @@
 gle.
-sps.data.VolunteeringOpportunity
+appengine.api.users.UserServiceFactory;%0Aimport com.google.sps.data.VolunteeringOpportunity;%0Aimport com.google.sps.data.OpportunitySignup
 ;%0Aim
@@ -705,16 +705,82 @@
 rvlet %7B%0A
+  private static final String OPPORTUNITY_ID = %22opportunity-id%22;%0A%0A
   /**%0A  
@@ -1629,16 +1629,29 @@
 ();%0A    
+SpannerTasks.
 insertOp

Call database function for insert in form handler.