index.jsp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" session="true"%>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  3. <%-- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> --%>
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  7. <title>Insert title here</title>
  8. </head>
  9. <%
  10. session = request.getSession();
  11. String sessionValue = "null Name.....";
  12. if (null != session.getAttribute("name")) {
  13. sessionValue = (String) session.getAttribute("name");
  14. }
  15. if ("Start".equals(request.getParameter("bSubmit"))) {
  16. session.setAttribute("name", request.getParameter("tName"));
  17. java.time.format.DateTimeFormatter dtf1 = java.time.format.DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
  18. java.time.LocalDateTime now1 = java.time.LocalDateTime.now();
  19. session.setAttribute("currTime", now1);
  20. %>
  21. <jsp:forward page="home.jsp" />
  22. <%
  23. }
  24. %>
  25. <body>
  26. <center>
  27. <font color="red" size=5><u>Welcome to Session Testing</u></font><br />
  28. <br />
  29. <%
  30. java.time.format.DateTimeFormatter dtf = java.time.format.DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
  31. java.time.LocalDateTime now = java.time.LocalDateTime.now();
  32. %>
  33. Current time :
  34. <%=now%>
  35. </center>
  36. <br />
  37. <br />
  38. <form action="index.jsp" method="get">
  39. <table align="center">
  40. <tr>
  41. <td>Enter Name :</td>
  42. <%-- <td><input type="text" name="tName"
  43. value="<%=("".equals(sessionValue) || (null == sessionValue)) ? "" : sessionValue%>">
  44. <td> --%>
  45. <td><input type="text" name="tName"
  46. value="${sessionValue}">
  47. <td>
  48. </tr>
  49. <tr>
  50. <td colspan="2"><input type="submit" name="bSubmit" value="Start"></td>
  51. </tr>
  52. </table>
  53. </form>
  54. </body>
  55. </html>