package net.mybluemix.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.util.Enumeration;

/**
 * Servlet implementation class SimpleServlet
 */
@WebServlet("/SimpleServlet")
public class SimpleServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        String fullMessage = "Hello World from Gearoid!\n";
        System.out.println(fullMessage);
        Enumeration headerNames = request.getHeaderNames();
		while (headerNames.hasMoreElements()) {
			String key = (String) headerNames.nextElement();
			String value = request.getHeader(key);
			fullMessage += "Header Key: " + key + ", Header Value: " + value;
			System.out.println("Header Key: " + key + ", Header Value: " + value);
		}
		response.getWriter().print(fullMessage);
    }
	
	/**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        Enumeration headerNames = request.getHeaderNames();
		while (headerNames.hasMoreElements()) {
			String key = (String) headerNames.nextElement();
			String value = request.getHeader(key);
			System.out.println("Header Key: " + key + ", Header Value: " + value);
		}
    }

}

@@ -1605,34 +1605,40 @@
 tHeaderNames();%0A
-%09%09
+        
 while (headerNam
@@ -1654,34 +1654,40 @@
 eElements()) %7B%0A%09
-%09%09
+        
 String key = (St
@@ -1712,34 +1712,40 @@
 nextElement();%0A%09
-%09%09
+        
 String value = r
@@ -1768,18 +1768,24 @@
 (key);%0A%09
-%09%09
+        
 System.o
@@ -1847,19 +1847,352 @@
 value);%0A
-%09%09%7D
+    %09%7D%0A        StringBuffer jb = new StringBuffer();%0A        String line = null;%0A        try %7B%0A            BufferedReader reader = request.getReader();%0A            while ((line = reader.readLine()) != null)%0A                jb.append(line);%0A        %7D catch (Exception e) %7B /*report an error*/ %7D%0A        System.out.println(jb.toString());
 %0A    %7D%0A%0A

Update SimpleServlet.java