SlideShare a Scribd company logo
1 of 6
AJAVA(2160707) 140120107100
Page No: 1
Report on Open Ended Problem (OEP)
(Academic Year: 2016-2017)
Subject Code: 2160707
Subject Name: Advanced Java
Definition of OEP: Create a shopping application using Servlet technology to display all the
times added in the cart. Design the following pages:-
a. Home page containing the gallery of items in the form of thumbnails. Below each
thumbnail display the price and item code for that item. Also there must be checkbox
displaying the text to add to cart below the prices of each item. User can click on multiple
checkboxes to add the item in his cart. At the bottom of the page there must be a submit
button which when clicked, control must be redirected to another page.
b. Display page must add the selected item’s code and its price in cookie and read those
values from cookie to display those items that are selected from the previous page. Also
display the details of each item (i.e. item code and price) in a tabular form.
Submitted By
Enrollment Number: 140120107100
Name: Siddharth Panchal
Branch: CE
Division & Batch: B-B2
Guided By
Name of Faculty: Prof. Mukesh Parmar
Department: CE
AJAVA(2160707) 140120107100
Page No: 2
INDEX
1. Definition:
Create a shopping application using Servlet technology to display all the times added in the cart.
Design the following pages:-
a. Home page containing the gallery of items in the form of thumbnails. Below each
thumbnail display the price and item code for that item. Also there must be checkbox
displaying the text to add to cart below the prices of each item. User can click on multiple
checkboxes to add the item in his cart. At the bottom of the page there must be a submit
button which when clicked, control must be redirected to another page.
b. Display page must add the selected item’s code and its price in cookie and read those
values from cookie to display those items that are selected from the previous page. Also
display the details of each item (i.e. item code and price) in a tabular form.
2. Implementation Code:
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<table border="1px">
<form action="addtocart">
<th>Pizza Name</th> <th>Price</th> <th>Add to Cart</th>
<tr><td>Muffuleta</td><td>$20</td><td><input type="hidden" name="name"
value="Muffuleta">
<input type="hidden" name="price" value="20"><input type="submit" value="Add to
cart"></td>
</tr>
</form>
<form action="addtocart">
<tr><td>Veggie Delight</td><td>$40</td><td>
<input type="hidden" name="name" value="Veggie Delight">
<input type="hidden" name="price" value="40"><input type="submit" value="Add to
cart"></td>
</tr>
</form>
AJAVA(2160707) 140120107100
Page No: 3
<form action="addtocart">
<tr><td>Margherita</td><td>$10</td><td>
<input type="hidden" name="name" value="margherita">
<input type="hidden" name="price" value="10"><input type="submit" value="Add to
cart"></td>
</tr>
</form>
</table>
</body>
</html>
import java.util.HashMap;
/**
*
* @author rajat
*/
public class Cart {
HashMap<String, Integer> cartItems;
public Cart(){
cartItems = new HashMap<>();
}
public HashMap getCartItems(){
return cartItems;
}
public void addToCart(String itemId, int price){
cartItems.put(itemId, price);
}
}
Shopping Cart Servlet
public class Addtocart extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
HttpSession session = request.getSession();
cart shoppingCart;
shoppingCart = (cart) session.getAttribute("cart");
if(shoppingCart == null){
shoppingCart = new cart();
session.setAttribute("cart", shoppingCart);
}
String name = request.getParameter("name");
Integer price = Integer.parseInt(request.getParameter("price"));
shoppingCart.addToCart(name, price);
session.setAttribute("cart", shoppingCart);
AJAVA(2160707) 140120107100
Page No: 4
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>result</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Pizza successfully added to cart </h1>");
out.println("<form action='index.html'>Add more pizza item<input type='submit'
value='go'></form>");
out.println("<hr>");
out.println("<h2>Cart</h2>");
HashMap<String, Integer> items = shoppingCart.getCartItems();
out.println("<table border='1px'>");
for(String key: items.keySet()){
out.println("<tr><td>"+key+" - </td><td>"+"$"+items.get(key)+"</td></tr>");
}
out.println("<table>");
out.println("</body>");
out.println("</html>");
}
}
To delete items from the shopping cart
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
String name = request.getParameter("name");
HttpSession session = request.getSession();
cart shoppingCart;
shoppingCart = (cart) session.getAttribute("cart");
shoppingCart.deleteFromCart(name);
session.setAttribute("cart", shoppingCart);
shoppingCart = (cart) session.getAttribute("cart");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet deleteItem</title>");
out.println("</head>");
out.println("<body>");
HashMap<String, Integer> items = shoppingCart.getCartItems();
out.println("<table border='1px'>");
for(String key: items.keySet()){
AJAVA(2160707) 140120107100
Page No: 5
out.println("<form action='deleteItem'><input type='hidden' name='name'
value='"+key+"'><tr><td>"+key+" - </td><td>"+"$"+items.get(key)+"</td><td><input
type='submit' value='delete'></td></tr></form>");
}
out.println("<table>");
out.println("</body>");
out.println("</html>");
}
}
3. ScreenShotof Implementation:
AJAVA(2160707) 140120107100
Page No: 6

More Related Content

Similar to Ajava oep shopping application

Create a mobile web app with Sencha Touch
Create a mobile web app with Sencha TouchCreate a mobile web app with Sencha Touch
Create a mobile web app with Sencha Touch
James Pearce
 
Hello I a having an issue with the code written in this ass.pdf
Hello I a having an issue with the code written in this ass.pdfHello I a having an issue with the code written in this ass.pdf
Hello I a having an issue with the code written in this ass.pdf
absgroup9793
 
Building a Mobile App with Sencha Touch
Building a Mobile App with Sencha TouchBuilding a Mobile App with Sencha Touch
Building a Mobile App with Sencha Touch
James Pearce
 
The Design of Motion - Creating Movement without Flash - Jesse Hodges, AspDot...
The Design of Motion - Creating Movement without Flash - Jesse Hodges, AspDot...The Design of Motion - Creating Movement without Flash - Jesse Hodges, AspDot...
The Design of Motion - Creating Movement without Flash - Jesse Hodges, AspDot...
AspDotNetStorefront
 

Similar to Ajava oep shopping application (20)

Create a mobile web app with Sencha Touch
Create a mobile web app with Sencha TouchCreate a mobile web app with Sencha Touch
Create a mobile web app with Sencha Touch
 
Lecture9
Lecture9Lecture9
Lecture9
 
Creating web api and consuming part 2
Creating web api and consuming part 2Creating web api and consuming part 2
Creating web api and consuming part 2
 
Jetpack Compose - A Lightning Tour
Jetpack Compose - A Lightning TourJetpack Compose - A Lightning Tour
Jetpack Compose - A Lightning Tour
 
Flamingo Commerce Module Details
Flamingo Commerce Module DetailsFlamingo Commerce Module Details
Flamingo Commerce Module Details
 
Documentation For Tab Setup
Documentation For Tab SetupDocumentation For Tab Setup
Documentation For Tab Setup
 
Html forms
Html formsHtml forms
Html forms
 
Hello I a having an issue with the code written in this ass.pdf
Hello I a having an issue with the code written in this ass.pdfHello I a having an issue with the code written in this ass.pdf
Hello I a having an issue with the code written in this ass.pdf
 
Share Point
Share PointShare Point
Share Point
 
E-Bazaar
E-BazaarE-Bazaar
E-Bazaar
 
Building a Mobile App with Sencha Touch
Building a Mobile App with Sencha TouchBuilding a Mobile App with Sencha Touch
Building a Mobile App with Sencha Touch
 
The Design of Motion - Creating Movement without Flash - Jesse Hodges, AspDot...
The Design of Motion - Creating Movement without Flash - Jesse Hodges, AspDot...The Design of Motion - Creating Movement without Flash - Jesse Hodges, AspDot...
The Design of Motion - Creating Movement without Flash - Jesse Hodges, AspDot...
 
Managing states
Managing statesManaging states
Managing states
 
How to check Google Analytics tags
How to check Google Analytics tagsHow to check Google Analytics tags
How to check Google Analytics tags
 
Creating web api and consuming- part 1
Creating web api and consuming- part 1Creating web api and consuming- part 1
Creating web api and consuming- part 1
 
A mobile web app for Android in 75 minutes
A mobile web app for Android in 75 minutesA mobile web app for Android in 75 minutes
A mobile web app for Android in 75 minutes
 
How to integrate paytm payment gateway using react js in seven easy steps
How to integrate paytm payment gateway using react js in seven easy stepsHow to integrate paytm payment gateway using react js in seven easy steps
How to integrate paytm payment gateway using react js in seven easy steps
 
Add row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.netAdd row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.net
 
Add row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.netAdd row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.net
 
Chapter09
Chapter09Chapter09
Chapter09
 

More from Paneliya Prince (20)

140120107044 ins ala.ppt
140120107044 ins ala.ppt140120107044 ins ala.ppt
140120107044 ins ala.ppt
 
To create a web service
To create a web serviceTo create a web service
To create a web service
 
Session and state management
Session and state managementSession and state management
Session and state management
 
Master pages
Master pagesMaster pages
Master pages
 
Master page
Master pageMaster page
Master page
 
Introduction to ado.net
Introduction to ado.netIntroduction to ado.net
Introduction to ado.net
 
Grid view control
Grid view controlGrid view control
Grid view control
 
Asp.net validation
Asp.net validationAsp.net validation
Asp.net validation
 
Asp.net control
Asp.net controlAsp.net control
Asp.net control
 
Wt oep visiting card
Wt oep visiting cardWt oep visiting card
Wt oep visiting card
 
SE OEP online car service booking
SE OEP online car service bookingSE OEP online car service booking
SE OEP online car service booking
 
creating jdbc connection
creating jdbc connectioncreating jdbc connection
creating jdbc connection
 
processing control input
processing control inputprocessing control input
processing control input
 
static dictionary technique
static dictionary techniquestatic dictionary technique
static dictionary technique
 
creating jdbc connection
creating jdbc connectioncreating jdbc connection
creating jdbc connection
 
DCDR
DCDRDCDR
DCDR
 
static dictionary
static dictionarystatic dictionary
static dictionary
 
ADO.net control
ADO.net controlADO.net control
ADO.net control
 
web technology
 web technology web technology
web technology
 
browse architecture and website structure
browse architecture and website structurebrowse architecture and website structure
browse architecture and website structure
 

Recently uploaded

Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 

Recently uploaded (20)

FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 

Ajava oep shopping application

  • 1. AJAVA(2160707) 140120107100 Page No: 1 Report on Open Ended Problem (OEP) (Academic Year: 2016-2017) Subject Code: 2160707 Subject Name: Advanced Java Definition of OEP: Create a shopping application using Servlet technology to display all the times added in the cart. Design the following pages:- a. Home page containing the gallery of items in the form of thumbnails. Below each thumbnail display the price and item code for that item. Also there must be checkbox displaying the text to add to cart below the prices of each item. User can click on multiple checkboxes to add the item in his cart. At the bottom of the page there must be a submit button which when clicked, control must be redirected to another page. b. Display page must add the selected item’s code and its price in cookie and read those values from cookie to display those items that are selected from the previous page. Also display the details of each item (i.e. item code and price) in a tabular form. Submitted By Enrollment Number: 140120107100 Name: Siddharth Panchal Branch: CE Division & Batch: B-B2 Guided By Name of Faculty: Prof. Mukesh Parmar Department: CE
  • 2. AJAVA(2160707) 140120107100 Page No: 2 INDEX 1. Definition: Create a shopping application using Servlet technology to display all the times added in the cart. Design the following pages:- a. Home page containing the gallery of items in the form of thumbnails. Below each thumbnail display the price and item code for that item. Also there must be checkbox displaying the text to add to cart below the prices of each item. User can click on multiple checkboxes to add the item in his cart. At the bottom of the page there must be a submit button which when clicked, control must be redirected to another page. b. Display page must add the selected item’s code and its price in cookie and read those values from cookie to display those items that are selected from the previous page. Also display the details of each item (i.e. item code and price) in a tabular form. 2. Implementation Code: <!DOCTYPE html> <html> <head> <title>TODO supply a title</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width"> </head> <body> <table border="1px"> <form action="addtocart"> <th>Pizza Name</th> <th>Price</th> <th>Add to Cart</th> <tr><td>Muffuleta</td><td>$20</td><td><input type="hidden" name="name" value="Muffuleta"> <input type="hidden" name="price" value="20"><input type="submit" value="Add to cart"></td> </tr> </form> <form action="addtocart"> <tr><td>Veggie Delight</td><td>$40</td><td> <input type="hidden" name="name" value="Veggie Delight"> <input type="hidden" name="price" value="40"><input type="submit" value="Add to cart"></td> </tr> </form>
  • 3. AJAVA(2160707) 140120107100 Page No: 3 <form action="addtocart"> <tr><td>Margherita</td><td>$10</td><td> <input type="hidden" name="name" value="margherita"> <input type="hidden" name="price" value="10"><input type="submit" value="Add to cart"></td> </tr> </form> </table> </body> </html> import java.util.HashMap; /** * * @author rajat */ public class Cart { HashMap<String, Integer> cartItems; public Cart(){ cartItems = new HashMap<>(); } public HashMap getCartItems(){ return cartItems; } public void addToCart(String itemId, int price){ cartItems.put(itemId, price); } } Shopping Cart Servlet public class Addtocart extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); HttpSession session = request.getSession(); cart shoppingCart; shoppingCart = (cart) session.getAttribute("cart"); if(shoppingCart == null){ shoppingCart = new cart(); session.setAttribute("cart", shoppingCart); } String name = request.getParameter("name"); Integer price = Integer.parseInt(request.getParameter("price")); shoppingCart.addToCart(name, price); session.setAttribute("cart", shoppingCart);
  • 4. AJAVA(2160707) 140120107100 Page No: 4 try (PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following sample code. */ out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>result</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>Pizza successfully added to cart </h1>"); out.println("<form action='index.html'>Add more pizza item<input type='submit' value='go'></form>"); out.println("<hr>"); out.println("<h2>Cart</h2>"); HashMap<String, Integer> items = shoppingCart.getCartItems(); out.println("<table border='1px'>"); for(String key: items.keySet()){ out.println("<tr><td>"+key+" - </td><td>"+"$"+items.get(key)+"</td></tr>"); } out.println("<table>"); out.println("</body>"); out.println("</html>"); } } To delete items from the shopping cart protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); String name = request.getParameter("name"); HttpSession session = request.getSession(); cart shoppingCart; shoppingCart = (cart) session.getAttribute("cart"); shoppingCart.deleteFromCart(name); session.setAttribute("cart", shoppingCart); shoppingCart = (cart) session.getAttribute("cart"); try (PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following sample code. */ out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet deleteItem</title>"); out.println("</head>"); out.println("<body>"); HashMap<String, Integer> items = shoppingCart.getCartItems(); out.println("<table border='1px'>"); for(String key: items.keySet()){
  • 5. AJAVA(2160707) 140120107100 Page No: 5 out.println("<form action='deleteItem'><input type='hidden' name='name' value='"+key+"'><tr><td>"+key+" - </td><td>"+"$"+items.get(key)+"</td><td><input type='submit' value='delete'></td></tr></form>"); } out.println("<table>"); out.println("</body>"); out.println("</html>"); } } 3. ScreenShotof Implementation: