12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" session="true"%>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <%-- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> --%>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <title>Insert title here</title>
- </head>
- <%
- session = request.getSession();
- String sessionValue = "null Name.....";
- if (null != session.getAttribute("name")) {
- sessionValue = (String) session.getAttribute("name");
- }
- if ("Start".equals(request.getParameter("bSubmit"))) {
- session.setAttribute("name", request.getParameter("tName"));
- java.time.format.DateTimeFormatter dtf1 = java.time.format.DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
- java.time.LocalDateTime now1 = java.time.LocalDateTime.now();
- session.setAttribute("currTime", now1);
- %>
- <jsp:forward page="home.jsp" />
- <%
- }
- %>
- <body>
- <center>
- <font color="red" size=5><u>Welcome to Session Testing</u></font><br />
- <br />
- <%
- java.time.format.DateTimeFormatter dtf = java.time.format.DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
- java.time.LocalDateTime now = java.time.LocalDateTime.now();
- %>
- Current time :
- <%=now%>
- </center>
- <br />
- <br />
- <form action="index.jsp" method="get">
- <table align="center">
- <tr>
- <td>Enter Name :</td>
- <%-- <td><input type="text" name="tName"
- value="<%=("".equals(sessionValue) || (null == sessionValue)) ? "" : sessionValue%>">
- <td> --%>
- <td><input type="text" name="tName"
- value="${sessionValue}">
- <td>
- </tr>
- <tr>
- <td colspan="2"><input type="submit" name="bSubmit" value="Start"></td>
- </tr>
- </table>
- </form>
- </body>
- </html>
|