package com.google.sps.servlets;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserServiceFactory;
import com.google.sps.data.OpportunitySignup;
import com.google.sps.utilities.SpannerTasks;
import java.io.IOException;
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 signing up for opportunities. */
@WebServlet("/opportunity-signup-form-handler")
public class OpportunitySignupFormHandlerServlet extends HttpServlet {
  private static final String OPPORTUNITY_ID = "opportunity-id";

  /**
   * Inserts opportunity signup with parameter value for name and current user email.
   *
   * @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 = request.getParameter(OPPORTUNITY_ID);
    User user = UserServiceFactory.getUserService().getCurrentUser();

    if (opportunityId == null) {
      response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Opportunity ID not specified.");
    } else if (user == null) {
      response.sendRedirect("/index.html");
    } else {
      OpportunitySignup signup =
          new OpportunitySignup.Builder(opportunityId, user.getEmail()).build();
      SpannerTasks.insertOpportunitySignup(signup);

      response.sendRedirect("/event-details.html");
    }   
  }
}

@@ -695,16 +695,69 @@
 ity-id%22;
+%0A  private static final String EVENT_ID = %22event-id%22;
 %0A%0A  /**%0A
@@ -1158,16 +1158,69 @@
 TY_ID);%0A
+    String eventId = request.getParameter(EVENT_ID);%0A
     User
@@ -1281,20 +1281,147 @@
 User();%0A
-%0A
    
+ %0A    if (eventId == null) %7B%0A      response.sendError(HttpServletResponse.SC_BAD_REQUEST, %22Event ID not specified.%22);%0A    %7D else
  if (opp
@@ -1820,16 +1820,30 @@
 edirect(
+String.format(
 %22/event-
@@ -1850,25 +1850,46 @@
 details.html
-%22
+?eventId=%25s%22, eventId)
 );%0A    %7D   %0A

Change redirect URL in servlet.