//2012-12-02 johnpfeiffer
/*
* Incoming Request -> CONTROLLER <- (business logic and data) -> MODEL
* |
* | (populate data for view)
* |
* Rendered response <- VIEW
*
*/
package net.kittyandbear;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Echo extends HttpServlet
{
private static final long serialVersionUID = 1L;
protected void doGet( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException
{
response.setContentType( "text/plain" ); // MIME type
PrintWriter servletresponse = null;
servletresponse = response.getWriter();
Map <String,String[]> parameterMap = request.getParameterMap();
// Iterator it = map.entrySet().iterator();
Iterator <Map.Entry <String , String[]>> it = request.getParameterMap().entrySet().iterator();
while( it.hasNext() )
{
Map.Entry entry = (Map.Entry) it.next();
System.out.println( entry.getValue() );
}
}
protected void doPost( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException
{
doGet( request, response);
}
} //end class
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.kittyandbear</groupId>
<artifactId>echo</artifactId>
<packaging>war</packaging>
<version>0.1</version>
<name>echo</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.vm.version>1.6</java.vm.version>
<maven.compiler.plugin.version>2.5.1</maven.compiler.plugin.version>
<junit.version>4.11</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>echo</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>${java.vm.version}</source>
<target>${java.vm.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<port>8080</port>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
</project>