ja24
-
Write a java program to scroll the text from left to right continuously. [15 M]
public class TextScrolling {
public static void main(String[] args) throws InterruptedException {
String text = "Hello, World! "; // Text to scroll
int windowSize = 10; // Width of the scrolling windowwhile (true) { for (int i = 0; i < windowSize; i++) { System.out.print(" "); // Create space before the text } System.out.print(text); Thread.sleep(500); // Sleep for 0.5 seconds System.out.print("\r"); // Move cursor back to the beginning of the line text = text.substring(1) + text.charAt(0); // Shift text to the left }}
} -
Write a JSP script to accept username and password from user, if they are same then
display “Login Successfully” message in Login.html file, otherwise display “Login
Failed” Message in Error.html file.
<%@ page language="java" %>
<%@ page import="java.io.*" %>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
if (username != null && password != null && username.equals(password)) {
response.sendRedirect("Login.html?message=Login+Successfully");
} else {
response.sendRedirect("Error.html?message=Login+Failed");
}
%>