index.html
<html>
<head></head>
<body>
<h2>Enter Your Name</h2>
<form action="greet.jsp" method="post">
<label for="username">Name:</label>
<input type="text" id="username" name="username" required>
<input type="submit" value="Greet Me">
</form>
</body>
</html>
greet.jsp
<%@ page language="java" contentType="text/html”%>
<html>
<head>
</head>
<body>
<%
String userName = request.getParameter("username");
if (userName != null && !userName.isEmpty()) {
%>
<h2>Hello, <%= userName %>! Welcome.</h2>
<%
} else {
%>
<h2>Please enter your name.</h2>
<%
}
%>
<a href="index.html">Go Back</a>
</body>
</html>