0
0

Cookie基本

Posted at

<%@pagecontentType="text/html; charset=UTF-8"%>
<%@pageimport="java.util.Objects"%>

Servlet/JSPの基礎を学ぼう <% //Servletからのデータを取得 String userName = (String) request.getAttribute("userName"); String userAge = (String) request.getAttribute("userAge");
	//データが存在しない場合に空文字を置き
	userName = Objects.toString(userName, "");
	userAge = Objects.toString(userAge, "");
	%>
	
	<%-- Servletへの画面遷移(POSTメソッド --%>
	<formaction="<%= request.getContextPath() %>/cookie"method="post">
		<table>
			<tr>
				<th>氏名</th>
				<td><inputtype="text"name="name"value=<%= userName %>></td>
			</tr>
			<tr>
				<th>年齢</th>
				<td><inputtype="text"name="age"value=<%= userAge %> ></td>
			</tr>
		</table>
		<inputtype="submit"value="保存">
		
		<inputtype="checkbox"id="deleteCookie"name="deleteCookie"value="true">
		<labelfor="deleteCookie">クッキーを削除する</label>
	
	</form>
</body>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0