1. Design the following static web pages required for an online book store web site.
a. HOMEPAGE
Online Book Store
Online Book Store
Welcome to our online book store!
b. LOGINPAGE
Login | Online Book Store
Online Book Store
c. CATALOGEPAGE
Catalog | Online Book Store
Online Book Store
Book Catalog
Book Title
Author: Author Name
Price: $XX.XX
2. JSP program calculates Powers of 2 for integers in the range 0-10
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
Powers of 2
Powers of 2
Number
Power of 2
<%
for(int i = 0; i <= 10; i++) {
int power = (int) Math.pow(2, i);
%>
<%= i %>
<%= power %>
<% } %>
3. Write a PHP code to check whether given string is palindrome or not
";
echo "String 2 is " . (isPalindrome($string2) ? "a palindrome" : "not a palindrome") . " ";
echo "String 3 is " . (isPalindrome($string3) ? "a palindrome" : "not a palindrome") . " ";
?>
1. Design the scientific calculator and make event for each button using JavaScript.
let display = document.getElementById('display');
function appendToDisplay(value) {
display.value += value;
}
function clearDisplay() {
display.value = '';
}
// Add more functions for other calculator operations as needed
2. Write a jsp program for registration page (username, password, email, mobileno, clgname).
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
Registration Page
User Registration
3. PHP program to swap two numbers
";
echo "a = " . $a . " ";
echo "b = " . $b . " ";
swapNumbers($a, $b);
echo "After swapping: ";
echo "a = " . $a . " ";
echo "b = " . $b . " ";
?>
1. Design the following static web pages with the following attributes:
a. Basic Tags.
Basic Tags
3.Assume a variable “a “initialize its value to 1229. Using PHP code check whether the no. is prime or not.
1. Design a static web pages with the following attributes:
d. BUTTON
e. RADIO BUTTON
f. DROP DOWN
Static Web Page
Welcome to My Web Page
Radio Buttons
Dropdown
2. Write a jsp program to demonstrate param action tag.
Main Page
Main Page
Other Page
Other Page
<%
// Retrieving parameters using request.getParameter()
String name = request.getParameter("name");
String age = request.getParameter("age");
%>
Name: <%= name %>
Age: <%= age %>
3. program to print factorial of a number.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
Factorial Calculator
Factorial Calculator
<%
// Get the number from the request parameter
int number = Integer.parseInt(request.getParameter("number"));
// Initialize factorial to 1
int factorial = 1;
// Calculate factorial
for (int i = 1; i <= number; i++) {
factorial *= i;
}
%>
The factorial of <%= number %> is <%= factorial %>
1. Embedding JavaScript in HTML pages.
1. Inline JavaScript:
Inline JavaScript
Inline JavaScript Example
2. External JavaScript File:
External JavaScript
External JavaScript Example
2. Write a jsp program to find Fibonacci series.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
Fibonacci Series
Fibonacci Series
<%-- Define the number of terms --%>
<% int numTerms = 10; // Change this to the desired number of terms %>
<%-- Initialize the first two terms of the Fibonacci series --%>
<% int firstTerm = 0; %>
<% int secondTerm = 1; %>
<%-- Display the first two terms --%>
<%= firstTerm %>
<%= secondTerm %>
<%-- Generate and display the remaining terms of the Fibonacci series --%>
<%
for (int i = 2; i < numTerms; i++) {
int nextTerm = firstTerm + secondTerm;
firstTerm = secondTerm;
secondTerm = nextTerm;
%>
<%= nextTerm %>
<% } %>
3. PHP code to Reverse String with and Without using strrev() function.
With strrev():
";
echo "Reversed string (with strrev()): $reversedString";
?>
Without strrev():
= 0; $i--) {
$reversedString .= $string[$i];
}
echo "Original string: $string ";
echo "Reversed string (without strrev()): $reversedString";
?>
1. Program to create a class calculator that contains an overloaded method called "add" to calculate the sum of two integers, two float numbers and, one integer and one float.
add(2, 3) . " ";
echo "Sum of 2.5 and 3.5 (float numbers): " . $calculator->add(2.5, 3.5) . " ";
echo "Sum of 2 and 3.5 (one integer and one float): " . $calculator->add(2, 3.5) . " ";
?>
2. Write a jsp program to check whether given no is palindrome or not.
Palindrome Checker
Palindrome Checker
<%
// Get the number from the request parameter
int number = Integer.parseInt(request.getParameter("number"));
// Convert the number to a string for comparison
String original = Integer.toString(number);
String reversed = new StringBuilder(original).reverse().toString();
// Check if the original number is equal to its reverse
boolean isPalindrome = original.equals(reversed);
%>
Number: <%= number %>
<% if (isPalindrome) { %>
<%= number %> is a palindrome.
<% } else { %>
<%= number %> is not a palindrome.
<% } %>
3.Write a PHP code to add n number of numbers by creating add() function
";
echo "Sum of 3 numbers: " . add(10, 20, 30) . " ";
echo "Sum of 5 numbers: " . add(1, 2, 3, 4, 5) . " ";
?>
1.Design the following static web pages required for an online book store web site.
A) HOMEPAGE
Bookstore Homepage
Welcome to Our Online Bookstore
New Arrivals
b) LOGINPAGE
Login - Bookstore
Login to Your Account
1. Write a jsp program to find factorial of a number.
Factorial Calculator
Factorial Calculator
<%
// Get the number from the request parameter
int number = Integer.parseInt(request.getParameter("number"));
// Calculate factorial
int factorial = 1;
for (int i = 1; i <= number; i++) {
factorial *= i;
}
%>
Factorial of <%= number %> is <%= factorial %>
3.PHP code to check whether no. is even or odd
1. Write a Program to create popup boxes in Java Script.
Popup Boxes Example
Popup Boxes Example
2. Write a JSP code to demonstrate declaration tag and scriplet tag.
Declaration and Scriptlet Tags
Declaration and Scriptlet Tags
<%-- Declaration Tag --%>
<%!
int num1 = 10;
int num2 = 5;
%>
<%-- Scriptlet Tag --%>
<%
int sum = num1 + num2;
%>
Number 1: <%= num1 %>
Number 2: <%= num2 %>
Sum: <%= sum %>
3. Write a PHP code to print the following pattern.
";
}
?>
1. Demonstrate selectors(group,universal,child,descendent).
CSS Selectors
Title
Paragraph 1
Span 1
Paragraph 2
Span 2
Paragraph 3
2. Write a JSP code to demonstrate exceptional handling.
Exception Handling in JSP
Exception Handling in JSP
<%-- Try block --%>
<%
try {
int result = 10 / 0; // This will throw an ArithmeticException
out.println("Result: " + result); // This line will not be executed
} catch (ArithmeticException e) {
// Catch block to handle the exception
%>
An error occurred: <%= e.getMessage() %>
<% } %>
3. PHP code to demonstrate
$x (single dollar)
$$x (double dollar).
1.Write a java script program to find whether number is palindrome or not .
function isPalindrome(number) {
// Convert the number to a string
let numString = number.toString();
// Get the length of the string
let len = numString.length;
// Loop through half of the string's length
for (let i = 0; i < len / 2; i++) {
// Check if the character at index i is equal to the character at index len - 1 - i
if (numString[i] !== numString[len - 1 - i]) {
return false; // If not equal, it's not a palindrome
}
}
return true; // If all characters match, it's a palindrome
}
// Test the function
let number = 12321;
if (isPalindrome(number)) {
console.log(number + " is a palindrome.");
} else {
console.log(number + " is not a palindrome.");
}
1. Write a JSP program for session tracking using
a. Hidden fields
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
Session Tracking - Hidden Fields
Click Here
c. Cookies
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
Session Tracking - Cookies
Session Tracking - Cookies
<%-- Set a cookie with username --%>
<% response.addCookie(new Cookie("username", "John")); %>
Click Here
d. Session objects
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
Session Tracking - Session Objects
Session Tracking - Session Objects
<%-- Set username in session --%>
<% session.setAttribute("username", "John"); %>
Click Here
3.PHP program to check leap year.
1. Write JavaScript code that uses recursion
function factorial(n) {
// Base case: If n is 0 or 1, return 1
if (n === 0 || n === 1) {
return 1;
}
// Recursive case: Multiply n by factorial of (n - 1)
else {
return n * factorial(n - 1);
}
}
// Test the function
console.log("Factorial of 5:", factorial(5)); // Output: 120
2.Write a jsp program to demonstrate forward action tag.
Forward Action Tag Example
Forward Action Tag Example
<%-- Use forward action tag --%>
Welcome
Welcome
Welcome to our website!
3.PHP program to check for an Armstrong number.
0) {
$digit = $temp % 10;
$sum += pow($digit, $numDigits);
$temp = (int)($temp / 10);
}
// Check if the number is an Armstrong number
if ($sum == $number) {
return true;
} else {
return false;
}
}
// Test the function
$number = 153; // Example of an Armstrong number
if (isArmstrong($number)) {
echo "$number is an Armstrong number.";
} else {
echo "$number is not an Armstrong number.";
}
?>
1. Create table to display marks of a student using html tags.
Student Marks
Student Marks
Subject
Marks
Mathematics
85
Science
90
English
75
History
80
2.Write a jsp program to find Fibonacci series.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
Fibonacci Series
Fibonacci Series
<%
// Get the number of terms for Fibonacci series from the request parameter
int numTerms = Integer.parseInt(request.getParameter("numTerms"));
// Initialize variables for Fibonacci series
int firstTerm = 0, secondTerm = 1, nextTerm;
// Display the first two terms of Fibonacci series
out.println("Fibonacci Series up to " + numTerms + " terms:");
out.print(firstTerm + ", " + secondTerm + ", ");
// Generate and display the remaining terms of Fibonacci series
for (int i = 3; i <= numTerms; i++) {
nextTerm = firstTerm + secondTerm;
out.print(nextTerm);
if (i < numTerms) {
out.print(", ");
}
// Update firstTerm and secondTerm for next iteration
firstTerm = secondTerm;
secondTerm = nextTerm;
}
%>
3.PHP program to reverse a number
0) {
// Extract the last digit of the number
$digit = $number % 10;
// Append the digit to the reversed number
$reversedNumber = $reversedNumber * 10 + $digit;
// Remove the last digit from the number
$number = (int)($number / 10);
}
return $reversedNumber;
}
// Test the function
$number = 12345;
$reversed = reverseNumber($number);
echo "Original Number: $number ";
echo "Reversed Number: $reversed";
?>
1. Write a HTML code to display this webpage.
Login Page
Login Page
2. Find the time difference between the last created cookie and current cookie?
3.Write a PHP program to count the number of vowels in a given string.
1. Write a java script program to check if number is perfect or not.
function isPerfectNumber(number) {
let sum = 0;
for (let i = 1; i < number; i++) {
if (number % i === 0) {
sum += i;
}
}
return sum === number;
}
// Example usage:
let num = 28; // Change this number to test different values
if (isPerfectNumber(num)) {
console.log(num + " is a perfect number.");
} else {
console.log(num + " is not a perfect number.");
}
2.Write a jsp program to demonstrate scriptlets
<%@ page language="java" %>
Scriptlet Demo
Scriptlet Demo
<%
// Declare variables
String name = "John";
int age = 30;
// Perform some logic
if (age >= 18) {
%>
<%= name %> is an adult.
<%
} else {
%>
<%= name %> is a minor.
<%
}
%>
3.Write PHP code that takes a student's marks as input and prints out the corresponding grade based on the following grading system:
A+: 90 or above
A: 80-89
B+: 70-79
B: 60-69
C+: 50-59
C: 40-49
D: 30-39
F: Below 30
Document