Write a JSP script to accept a String from a user and
display it in reverse order.
<%@ page language="java" %>
<html>
<body>
<form
method="post">
Enter a String:
<input type="text"
name="inputString"><br><br>
<input
type="submit" value="Reverse">
</form>
<br><br>
<%
String
inputString = request.getParameter("inputString");
if (inputString
!= null && !inputString.isEmpty()) {
String
reversedString = new StringBuilder(inputString).reverse().toString();
out.println("Original String: " + inputString +
"<br>");
out.println("Reversed String: " + reversedString);
}
%>
</body>
</html>