Apache Tomcat - JSP basic
http post
post sample
file:formpost.jsp
<%@ page language="java" %> <%@ page contentType="text/html; charset=UTF-8" %> <%@ page pageEncoding="UTF-8" > <!DOCTYPE html> <html> <head> <title>Debug</title> </head> <body> <form action="./formpost.jsp" method="post"> <input type="text" name="hogePostData" /> <input type="submit" value="Send" /> </form> <br /> Recv: <%= request.getParameter("hogePostData") %> </body> </html>
file:ShowHeader.jsp
<%@ page language="java" %> <%@ page contentType="text/html; charset=UTF-8" %> <%@ page pageEncoding="UTF-8" %> <%@ page import="java.util.*" %> <!DOCTYPE html> <html> <head> <title>Show Headers</title> </head> <body> <table border="1"> <tr> <th>HeaderName</th> <th>Value</th> </tr> <% Enumeration<String> headers = request.getHeaderNames(); while ( headers.hasMoreElements() ) { String name = (String)headers.nextElement(); String value = request.getHeader(name); %> <tr> <td><%= name %></td> <td><%= value %></td> </tr> <% } %> </table> </body> </html>
file:ShowResHeader.jsp
<%@ page language="java" %> <%@ page contentType="text/html; charset=UTF-8" %> <%@ page pageEncoding="UTF-8" %> <%@ page import="java.util.*" %> <!DOCTYPE html> <html> <head> <title>Show Response Headers</title> </head> <body> <table border="1"> <tr> <th>HeaderName</th> <th>Value</th> </tr> <% Collection<String> headers = response.getHeaderNames(); Iterator keys = headers.iterator(); while (keys.hasNext() ) { String name = (String)keys.next(); String value = response.getHeader(name); >% <tr> <td><%= name %></td> <td><%= value %></td> </tr> <% } %> </table> </body> </html>