まとめ @ wiki

クッキーの取得

最終更新:

shells

- view
管理者のみ編集可

クッキーの取得 【HP


目次


ソース

request_cookie.jsp

<%@ page contentType="text/html;charset=Shift_JIS" %>
<%
	String strMal="";
	Cookie objCok=null;
	Cookie[] aryCok=request.getCookies();
	if(aryCok!=null){
		for(int i=0;i<aryCok.length;i++){
			if(aryCok[i].getName().equals("email")){
				strMal=aryCok[i].getValue();
			}
		}
	}
%>
 
<html>
<head>
	<title>クッキーの取得(requestオブジェクト3</title>
</head>
 
<body>
	<form method="POST" action="response_cookie.jsp">	<!-- response_cookie.jspは後に記述 -->
		E-Mailアドレス:
			<input type="text" name="email" size="50" value="<%=strMal%>" />
			<input type="submit" value="登録" />
	</form>
</html>

実行結果

一度入力した文字列をキャッシュに登録する

記事メニュー
ウィキ募集バナー