|
<%@ page
language="java"
import="java.io.*"
import="java.text.*"
import="java.util.*"
contentType="text/html;charset=utf-8" %>
<%!
public void outlog( ServletContext app,String message ) {
app.log( String.format("<<JSP>> %s", message ) );
}
%>
<%
// *********************************************************
// 入力値の表示
// GET で setCharacterEncoding を有効にするには
// server.xml => Connector で useBodyEncodingForURI="true"
// *********************************************************
request.setCharacterEncoding("utf-8"); // 入力値のエンコーディング
String strGet = request.getParameter("InputGet");
if ( strGet == null ) {
strGet = "";
}
else {
outlog( application, String.format("InputGet:%s", strGet ) );
}
String strPost = request.getParameter("InputPost");
if ( strPost == null ) {
strPost = "";
}
else {
outlog( application, String.format("InputPost:%s", strPost ) );
}
%>
<html>
<body>
フォーム : GET
<form method="get">
<input type="text" name="InputGet" value="<%= strGet %>">
<input type="submit" name="send" value="GET">
</form>
フォーム : POST
<form method="post">
<input type="text" name="InputPost" value="<%= strPost %>">
<input type="submit" name="send" value="POST">
</form>
getdata = <%= strGet %><br>
postdata = <%= strPost %><br>
</body>
</html>
| |