Commits

jfq authored 582cb583107
MOVED from https://svn.nspop.dk/svn/nsp/trunk/performance to here. Added room for SOR, LAR and NAS.

git-svn-id: https://svn.nspop.dk/svn/components/performance/trunk@121 3203d48c-b89f-428c-a2b9-71f4dc330d7c
No tags

modules/echo/src/main/java/com/arosii/nsp/echo/EchoWebService.java

Added
1 +/*
2 + * The contents of this file is the CONFIDENTAL and PROPRIETARY
3 + * property of Arosii Information Systems A/S. Any unauthorized use,
4 + * reproduction or transfer of this file is strictly prohibited.
5 + *
6 + * Copyright (C) 2012 Arosii Information Systems A/S. All rights reserved.
7 + * This is an unpublished work, and is subject to limited
8 + * distribution and restricted disclosure only.
9 + */
10 +package com.arosii.nsp.echo;
11 +
12 +import java.io.IOException;
13 +import java.io.PrintWriter;
14 +
15 +import javax.servlet.ServletException;
16 +import javax.servlet.ServletInputStream;
17 +import javax.servlet.ServletOutputStream;
18 +import javax.servlet.http.HttpServlet;
19 +import javax.servlet.http.HttpServletRequest;
20 +import javax.servlet.http.HttpServletResponse;
21 +
22 +/**
23 + *
24 + * @author Jacob
25 + */
26 +public class EchoWebService extends HttpServlet {
27 +
28 + private static final long serialVersionUID = 1L;
29 +
30 + /**
31 + * {@inheritDoc}
32 + */
33 + @Override
34 + protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
35 + PrintWriter out = new PrintWriter(httpServletResponse.getOutputStream());
36 + String pathInfo = httpServletRequest.getPathInfo();
37 + String echo = pathInfo != null ? (pathInfo.startsWith("/") ? pathInfo.substring(1) : pathInfo) : "";
38 + out.append("<html><body>" + echo + "</body></html>");
39 + out.flush();
40 + out.close();
41 + }
42 +
43 + /**
44 + * {@inheritDoc}
45 + */
46 + @Override
47 + protected void doPost(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
48 + ServletInputStream in = httpServletRequest.getInputStream();
49 + ServletOutputStream out = httpServletResponse.getOutputStream();
50 + byte[] buffer = new byte[1024];
51 + int len = 0;
52 + while ((len = in.read(buffer)) > 0) {
53 + out.write(buffer, 0, len);
54 + }
55 + out.flush();
56 + out.close();
57 + }
58 +}

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut