/******************************************************************************* * Copyright (c) 2009, 2017 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.ua.tests.help.util; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class LoadTestServlet extends HttpServlet { /** * */ private static final long serialVersionUID = -1426745453574711075L; private static final String XHTML_1 = "\n\n\n"; //$NON-NLS-1$ private static final String XHTML_2 = "\n \n\n"; //$NON-NLS-1$ private static final String XHTML_3 = "\n"; //$NON-NLS-1$ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ resp.setContentType("text/html; charset=UTF-8"); //$NON-NLS-1$ String value = req.getParameter("value"); String repeatParam = req.getParameter("repeat"); int repetitions = 200; try { repetitions = Integer.parseInt(repeatParam); } catch (NumberFormatException e) { } StringBuilder buf = new StringBuilder(); buf.append(""); buf.append(XHTML_1); buf.append(value); buf.append(XHTML_2); for (int i = 0; i < repetitions; i++) { buf.append("\n

"); buf.append("Paragraph" + i); buf.append("

"); } buf.append('$'); buf.append(XHTML_3); String response = buf.toString(); resp.getWriter().write(response); } }