Java tutorial
/* * * Copyright 2014 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.insomne.blackbush; import java.io.File; import java.io.IOException; import javax.servlet.http.*; import java.util.Scanner; import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; /** * @author Andres Leonardo Martinez Ortiz a.k.a almo * */ @SuppressWarnings("serial") public class BlackBushServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { GoogleClientSecrets clientSecrets = (GoogleClientSecrets) getServletContext().getAttribute("clientSecrets"); String CLIENT_ID = clientSecrets.getWeb().getClientId(); resp.getWriter() .print(new Scanner(new File("index.html"), "UTF-8").useDelimiter("\\A").next() .replaceAll("[{]{2}\\s*CLIENT_ID\\s*[}]{2}", CLIENT_ID) .replaceAll("[{]{2}\\s*APPLICATION_NAME\\s*[}]{2}", "BlackBush").toString()); resp.setStatus(HttpServletResponse.SC_OK); } }