Part A6
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> Fibo and Prime</title>
</head>
<body>
<h4>Fibonacci Series</h4>
<%
int a=0,b=1,c,i;
[Link](a+" "+b+" ");
for(i=1;i<=8;i++){
c=a+b;
[Link](c+" ");
a=b;
b=c;
%>
<h4>Prime Number</h4>
<%
int pn=2,count=1;
boolean isprime;
while(count<=10){
isprime=true;
for(i=2;i<=pn/2;i++){
if(pn%i==0){
isprime=false;
break;
if(isprime){
[Link](pn+" ");
count++;
pn++;
%>
</body>
</html>
Part A7
shoppingdemo
<%--
Document : ShoppingDemo
Created on : 29 Apr, 2026, 2:35:29 PM
Author : HP
--%>
<%@page import="[Link]"%>
<%@page import="[Link]"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Shopping</title>
</head>
<body>
<h1>Online Shopping</h1>
<%
ArrayList<Item> cart;
if([Link]().getAttribute("cart")==null) {
cart = new ArrayList<Item>();
[Link]().setAttribute("cart",cart);
}else{
cart = (ArrayList<Item>)[Link]().getAttribute("cart");
}
%>
<table width="100%">
<tr>
<td>
<form method="POST">
<img src="images/[Link]" alt="coca cola" height="200px"/>
<h4>Coca cola</h4>
<input type="hidden" value="coco cola" name="name">
price: Rs.35
<input type="hidden" value="35" name="price">
<br>
Quantity:
<input type="number" name="qty" value="1" width="2" style="width:30px">
<br>
<input type="submit" name="addBtn" value="Add">
</form>
</td>
<td>
<form method="POST">
<img src="images/[Link]" alt="pepsi" height="200px"/>
<h4>Pepsi</h4>
<input type="hidden" value="pepsi" name="name">
price: Rs.40
<input type="hidden" value="40" name="price">
<br>
Quantity:
<input type="number" name="qty" value="1" width="2" style="width:30px">
<br>
<input type="submit" name="addBtn" value="Add">
</form>
</td>
<td>
<form method="POST">
<img src="images/[Link]" alt="sprite" height="200px"/>
<h4>Sprite</h4>
<input type="hidden" value="sprite" name="name">
price: Rs.45
<input type="hidden" value="45" name="price">
<br>
Quantity:
<input type="number" name="qty" value="1" width="2" style="width:30px">
<br>
<input type="submit" name="addBtn" value="Add">
</form>
</td>
<td>
<form method="POST">
<img src="images/[Link]" alt="thums up" height="200px"/>
<h4>Thumbs up</h4>
<input type="hidden" value="thumbs up" name="name">
price: Rs.50
<input type="hidden" value="50" name="price">
<br>
Quantity:
<input type="number" name="qty" value="1" width="2" style="width:30px">
<br>
<input type="submit" name="addBtn" value="Add">
</form>
</td>
</tr>
</table>
<%
if([Link]("removeBtn")!=null) {
int index = [Link]([Link]("ino"));
[Link](index);
[Link]("<h4 style=\"color:green\">Item is removed</h4>");
if([Link]("addBtn")!=null) {
int qty = [Link]([Link]("qty"));
if(qty<0){
[Link]("<h4 style=\"color:red\">Please enter a positive value for quantity</h4>");
}else{
String name = [Link]("name");
boolean ItemFound = false;
for(int i=0;i<[Link]();i++){
Item item = [Link](i);
if([Link]().equals(name)) {
[Link]([Link]()+qty);
[Link]("<h4 style=\"color:blue\">Item:"+name+" added to the cart</h4>");
ItemFound = true;
break;
if(!ItemFound) {
double price = [Link]([Link]("price"));
Item itm = new Item(name, qty, price);
[Link](itm);
[Link]("<h4 style=\"color:blue\">Item:"+name+" added to the cart</h4>");
if([Link]()>0){
%>
<h2>Cart Details</h2>
<table border="2">
<tr>
<th>Item Name</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total</th>
<th>Action</th>
</tr>
<%
for(int i=0;i<[Link]();i++){
Item item = [Link](i);
%>
<tr>
<td><%= [Link]() %></td>
<td><%= [Link]() %></td>
<td><%= [Link]() %></td>
<td><%= [Link]()*[Link]() %></td>
<td>
<form method="POST">
<input type="hidden" value="<%=i%>" name="ino">
<input type="submit" value="Remove" name="removeBtn">
</form>
</td>
</tr>
<%
%>
</table>
<%
%>
</body>
</html>
[Link]
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com;
/**
*
* @author HP
*/
import [Link];
public class Item implements Serializable {
private String name;
private int qty;
private double price;
public Item() {
public Item(String name, int qty, double price) {
[Link] = name;
[Link] = qty;
[Link] = price;
public String getName() {
return name;
public void setName(String name) {
[Link] = name;
}
public int getQty() {
return qty;
public void setQty(int qty) {
[Link] = qty;
public double getPrice() {
return price;
public void setPrice(double price) {
[Link] = price;