- Write a JSP script to accept a String from a user and display it in reverse order.
[15 M]
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Reverse String</title>
</head>
<body>
<form action="ReverseString.jsp" method="post">
Enter a string: <input type="text" name="inputString">
<input type="submit" value="Reverse">
</form>
<%
String inputString = request.getParameter("inputString");
if (inputString != null && !inputString.isEmpty()) {
String reversedString = "";
for (int i = inputString.length() - 1; i >= 0; i--) {
reversedString += inputString.charAt(i);
}
out.println("<p>Reversed string: " + reversedString + "</p>");
}
%>
</body>
</html>
-
Write a java program to display name of currently executing Thread in multithreading.
-
public class CurrentThreadName {
public static void main(String[] args) {
Thread thread = new Thread(() -> {
System.out.println("Currently executing thread: " + Thread.currentThread().getName());
});
thread.start();
}
}