display current date – Programmerbay https://programmerbay.com A Tech Bay for Tech Savvy Mon, 04 Jul 2022 06:27:30 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 https://programmerbay.com/wp-content/uploads/2019/09/cropped-without-transparent-32x32.jpg display current date – Programmerbay https://programmerbay.com 32 32 Create an application to display current date and time in apache tomcat server https://programmerbay.com/create-an-application-to-display-current-date-and-time-in-apache-tomcat-server/ https://programmerbay.com/create-an-application-to-display-current-date-and-time-in-apache-tomcat-server/#respond Sun, 08 Dec 2019 14:06:53 +0000 https://programmerbay.com/?p=5669 Here is the code to display current date and time in the apache tomcat server.

  1. Create a landing page.

Index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Practical Work</title>
</head>
<body>
<form action="perform_something.jsp">

  <button type="submit">Click here to know current date and time</button><br/> </form>
</body>
</html

2. To show the current date and time, use Java date object in a JSP page.

Perform_Something.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="java.util.Date"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
Date da = new Date();

%>
Date:<%= da.toLocaleString() %>
</body>
</html>

Output:

 display current date in jsp

 

 

display current date in jsp 1

]]>
https://programmerbay.com/create-an-application-to-display-current-date-and-time-in-apache-tomcat-server/feed/ 0