Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for...

88
Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected] . Do not duplicate and do not give it to any other person or entity. Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7) published by Amazon, USA (ISBN: 978-1976901751) and Flushing Meadows Publishers, India (ISBN: 978-93-5300-898-7) Author - Ashfaque Ahmed

Transcript of Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for...

Page 1: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

Complimentary material for the book “Software Engineering in the Agile World”

(ISBN: 978-93-5300-898-7) published by Amazon, USA (ISBN: 978-1976901751) and Flushing Meadows Publishers, India (ISBN: 978-93-5300-898-7)

Author - Ashfaque Ahmed

Page 2: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

Multinational online store project

JSP files + Stylesheet file

style.css ------------ -------- @charset "utf-8"; /* CSS Document */ body{ margin:0; color:#CD5C5C; background:#CD5C5C; } div, h1, h2, h3, h4, p, form, label, input, textarea, img, span{ margin:0; padding:0; } ul{ margin:0; padding:0; list-style-type:none; font-size:0; line-height:0; } .spacer{ clear:both; font-size:0; line-height:0; } .more { font:normal 11px/18px Arial, Helvetica, sans-serif; color:#00d09d; text-decoration:none; padding-left:230px; } .style1{color:#00d09d;} /*------------------------------------------------body--------------------*/ #top_links { margin:0 auto;

Page 3: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

padding:0px; width:1000px; height:40px; } #top_linksin { padding:10px 0 0 0; width:310px; height:18px; float:right; } #top_linksin ul { list-style:none; margin:0 0 0 40px; } #top_linksin ul li { font:normal 11px/10px Arial, Helvetica, sans-serif; color:#FFFFFF; border-right:#7f7f7f 1px solid; padding:0 15px; float:left; } #top_linksin ul li a { text-decoration:none; display:block; color:#7f7f7f; } #top_linksin ul li a:hover { text-decoration:none; display:block; color:#FFFFFF; } #header { margin:0 auto; background:#CD5C5C 0 0 no-repeat; width:897px; height:182px; } #header h1

Page 4: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

{ font:bold 44px/18px Arial, Helvetica, sans-serif; color:#FFFFFF; padding:100px 0 0 380px; } #header h2 { font:bold italic 24px/18px Arial, Helvetica, sans-serif; color:#ababab; padding:20px 0 0 380px; } #navigation { margin:0 auto; width:1096px; height:40px; background:#000; border:1px solid #282828; } #navigation ul { list-style:none; } #navigation ul li { color:#adadad; float:left; text-align:center; font:bold 12px/40px Arial, Helvetica, sans-serif; width:127px; border-right:1px solid #282828; } #navigation ul li a { text-decoration:none; display:block; color:#adadad; } #navigation ul li a:hover { color:#FFFFFF; } #navigation ul li.last { border:none;

Page 5: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

float:left; } #content1 { width:1097px; margin:0 auto; background:url(images/globe_05.jpg) 0 0 repeat-y; } #content1 h1 { font:bold italic 22px/79px Arial, Helvetica, sans-serif; color:#ffffff; padding-left:30px; } #content1 p { font:normal 12px/18px Arial, Helvetica, sans-serif; color:#b2b2b2; padding:5px 15px 0 15px; } .con { background:url(images/globe_06.jpg) 0 0 repeat-y; width:290px; } #heade1 { width:167px; height:79px; background:url(images/image_03.gif) 20px 10px no-repeat; padding-left:90px; } #heade2 { width:167px; height:79px; background:url(images/image_04.gif) 20px 10px no-repeat; padding-left:90px; } #heade3 { width:167px; height:79px; background:url(images/image_05.gif) 20px 5px no-repeat; padding-left:90px;

Page 6: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

} #services { width:257px; padding:10px; } #services h1 { font:bold italic 20px/25px Arial, Helvetica, sans-serif; color:#333333; } #services ul { list-style:none; margin-left:8px; } #services ul li { font:normal 12px/22px Arial, Helvetica, sans-serif; color:#FFFFFF; display:block; padding:0 0 4px 16px; background:url(images/bullet.png) left center no-repeat; } #services ul li a { text-decoration:none; display:block; color:#7f7f7f; } #services ul li a:hover { text-decoration:none; display:block; color:#000000; } #welcome { width:287px; padding:10px; } #welcome h1 { font:bold italic 20px/25px Arial, Helvetica, sans-serif; color:#333333; }

Page 7: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

#welcome p { font:normal 12px/18px Arial, Helvetica, sans-serif; color:#7f7f7f; } #news { width:257px; padding:10px; } #news h1 { font:bold italic 20px/25px Arial, Helvetica, sans-serif; color:#333333; } .img { float:left; padding-right:10px; } #news h2 { font:bold 12px/18px Arial, Helvetica, sans-serif; color:#333333; } #news p { font:normal 12px/18px Arial, Helvetica, sans-serif; color:#7f7f7f; } #footer_navigation { width:500px; height:30px; margin:0 auto; } #footer_navigation ul li { width:80px; font: normal 12px/30px Arial, Helvetica, sans-serif; color:#7d9942; float:left; } #footer_navigation ul li a {

Page 8: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

text-decoration:none; color:#7f7f7f; height:30px; } #footer_navigation ul li a:hover { text-decoration:none; color:#ffffff; height:49px; } #footer_copyright { color: #7f7f7f; font: normal 11px/30px Arial, Helvetica, sans-serif; margin:0 auto; text-align:center; } #footer_design { color: #ffffff; font: normal 11px/25px Arial, Helvetica, sans-serif; margin:0 auto; text-align:center; width:100%; background:#000000; } #footer_design a { color: #b6ff06; text-decoration:none; } #footer_design a:hover { color: #b6ff06; text-decoration:underline; } admin_after_login.jsp ----------- --------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head>

Page 9: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> <li><a href="create_country_req.jsp">Create Country</a></li> <li><a href="create_product_req.jsp">Create Product</a></li> <li><a href="product_country_link_req.jsp">Link product to country</a></li> <li><a href="edit_profile.jsp">edit account</a></li> <li><a href="logout.jsp">Logout</a></li> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"><h1></h1> </div> </td> <td width="1200" valign="top"> <%

Page 10: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

String userName = null; String sessionID = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("username")) {userName = cookie.getValue();} }} else {response.sendRedirect("login.jsp");} %> <div id="welcome" style="border-right:#666666 1px dotted;"><h1>You have successfully logged in the system. PLEASE CHOOSE WHAT YOU WANT TO CREATE FROM THE TOP MENU</h1><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td> </td> </tr> </table> </div> </td> <td width="299" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"> <center></center> </div> </td> </tr></table> <div id="footer_top"> <div id="footer_navigation"> </div>

Page 11: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> </body> </html> ---------------- ----------------------- buy_req.jsp ----------- ------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> function validate(form) { for(var i=0; i<form.elements.length; i++) { if(form.elements[i].value == "") { alert("Fill out all Fields") //document.F1.username.focus() form.elements[i].focus() return false } }

Page 12: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

return true } </SCRIPT> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function ctck1() { var sds = document.getElementById("form"); } </script> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> </div> <% String country_ID =null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("countryID")) {country_ID = cookie.getValue();} }} Connection con=DB_connection.DBConnection(); String country = ""; int country_ID1=Integer.parseInt(country_ID); PreparedStatement ps=con.prepareStatement("Select name from country where no =?");

Page 13: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

ps.setInt(1, country_ID1); ResultSet rs=ps.executeQuery(); out.print("<table align='left' cellspacing='5' cellpadding='5'>"); while (rs.next()){ out.print("<tr><td><b>" + rs.getString(1) + " </b>Country site.</td></tr>");} out.print("</table"); %><% String product = null; String productID = null; Cookie[] cookies1 = request.getCookies(); if(cookies1 !=null){ for(Cookie cookie : cookies1){ if(cookie.getName().equals("productID")) {productID = cookie.getValue();} }} else {response.sendRedirect("index.jsp");} %> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"><h1></h1> </div> </td> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"><h1>Buy product</h1><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td> <form name=F1 id=F1 onSubmit="return validate(this)" action="buy_res.jsp" > <table cellspacing="5" cellpadding="3"> <tr><td> Product Quantity:</td><td><input type="text" name="product_qty" /></td></tr>

Page 14: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<tr><td> Buyer's Name:</td><td><input type="text" name="name" /></td></tr> <tr><td> Buyer's Address:</td><td><input type="text" name="address" /></td></tr> <tr><td> Buyer's Phone:</td><td><input type="text" name="phone" /></td></tr> <tr><td>Buyer's Email:</td><td> <input type="text" name="email"/></td></tr> <tr><td><input type="submit" name = submit value="Submit"/></td> <td><INPUT TYPE=RESET name = reset VALUE="CLEAR"/></td></tr> </table> </form> </td> </tr> </table> </div> </td> <td width="299" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"> <center></center> </div> </td> </tr></table> <div id="footer_top"> <div id="footer_navigation"> </div> <div id="footer_copyright" > <center></center><br>

Page 15: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> </body> </html> ------------- ---------------------- buy_res.jsp -------- -------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1>

Page 16: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> </div> <div id="navigation"> <ul> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <% String country = null; int country_int= 0; String countryID1 = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("countryID")) {countryID1 = cookie.getValue();} } } else {response.sendRedirect("index.jsp");} country_int= Integer.parseInt(countryID1); Connection con=DB_connection.DBConnection(); PreparedStatement ps=con.prepareStatement("Select name from country where no =?"); ps.setInt(1, country_int); ResultSet rs=ps.executeQuery(); out.print("<table align='left' cellspacing='5' cellpadding='5'>"); while (rs.next()){ out.print("<tr><td><b>" + rs.getString(1) + " </b>Country site.</td></tr>");} out.print("</table");

Page 17: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

int product_int = 0; String productID = null; Cookie[] cookies1 = request.getCookies(); if(cookies1 !=null){ for(Cookie cookie : cookies1){ if(cookie.getName().equals("productID")) {productID = cookie.getValue();} }} else {response.sendRedirect("index.jsp");} product_int= Integer.parseInt(productID); %> <% try { String name =request.getParameter("name"); String address =request.getParameter("address"); String phone = request.getParameter("phone"); int phone_int=Integer.parseInt(phone); String email = request.getParameter("email"); Connection con1=DB_connection.DBConnection(); PreparedStatement ps1=con1.prepareStatement("insert into buyer values(?,?,?,?,?,?,?,?,?)"); int buyer_no=DB_connection.getPrimaryKey(); ps1.setInt(1, buyer_no); ps1.setString(2,name); ps1.setString(3,address); ps1.setString(4,email); ps1.setInt(5,phone_int); ps1.setString(6," "); ps1.setInt(7,0); ps1.setString(8," "); ps1.setDate(9,new java.sql.Date(new java.util.Date().getTime())); ps1.executeUpdate(); ps1.close(); String product_qty =request.getParameter("product_qty"); int product_qty_int=Integer.parseInt(product_qty); Double shipping_charge=0.00; Double tax_charge=0.00; Double total_amount=0.00; Double product_price=0.00; Connection con2=DB_connection.DBConnection();

Page 18: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

PreparedStatement ps2=con2.prepareStatement("select product_price from product_country where country_no=? and product_no=?"); ps2.setInt(1, country_int); ps2.setInt(2, product_int); ResultSet rs2=ps2.executeQuery(); while(rs2.next()){ product_price = rs2.getDouble(1); } ps2.close(); rs2.close(); Connection con3=DB_connection.DBConnection(); PreparedStatement ps3=con3.prepareStatement("select tax_rate, shipping_rate from country where no=?"); ps3.setInt(1, country_int); ResultSet rs3=ps3.executeQuery(); while(rs3.next()){ shipping_charge = rs3.getDouble(2); tax_charge = rs3.getDouble(1)*product_price*product_qty_int/100; total_amount= shipping_charge+tax_charge+product_price*product_qty_int; String product_name = null; Connection con4=DB_connection.DBConnection(); PreparedStatement ps4=con4.prepareStatement("select name from product where no=? "); ps4.setInt(1, product_int); ResultSet rs4=ps4.executeQuery(); while(rs4.next()){ product_name = rs4.getString(1); } String dimension = null; Cookie[] cookies3 = request.getCookies(); if(cookies3 !=null){ for(Cookie cookie : cookies3){ if(cookie.getName().equals("dimension")) {dimension = cookie.getValue();} }} out.print("<tr><th>PRODUCT NAME:</th><th>"+product_name+"</th></tr>"); out.print("<tr><th>PRODUCT DIMENSION::</th><th>"+dimension+"</th></tr>");

Page 19: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

out.print("<tr><th>PRODUCT QUANTITY:</th><th>"+product_qty_int+"</th></tr>"); out.print("<tr><th>PRODUCT PRICE PER UNIT::</th><th>"+product_price+"</th></tr>"); out.print("<tr><th>PRODUCT COST:</th><th>"+product_price*product_qty_int+"</th></tr>"); out.print("<tr><th>SHIPPING CHARGE:</th><th>"+shipping_charge+"</th></tr>"); out.print("<tr><th>TAX:</th><th>"+tax_charge+"</th></tr>"); out.print("<tr><th>TOTAL PAYMENT::</th><th>"+total_amount+"</th></tr>"); } out.print("</table>"); ps3.close(); rs3.close(); String total_amount_String= Double.toString(total_amount); Cookie amount = new Cookie("total_amount", total_amount_String); amount.setMaxAge(30*60); response.addCookie(amount); String buyer_string= Integer.toString(buyer_no); Cookie buyerID = new Cookie("buyerID", buyer_string); buyerID.setMaxAge(30*60); response.addCookie(buyerID); Cookie product_qty_c = new Cookie("product_qty", product_qty); product_qty_c.setMaxAge(30*60); response.addCookie(product_qty_c); } catch (SQLException e) { e.printStackTrace(); } %></table> <tr> <td width="1200" valign="top"> <a href="pay_req.jsp"><h1 >Pay</h1 ></a> <br> </tr>

Page 20: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<table> </table> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> --------------- ---------------------------- create_acc_admin_req.jsp ------------- ---------------------- create_acc_student_req.jsp ------------ --------------- ----------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> function validate(form) { for(var i=0; i<3; i++) { if(!isNaN(form.elements[i].value)) { alert("This Field must be in Characters") form.elements[i].value="" form.elements[i].focus() return false } }

Page 21: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

if(document.F1.password.value!=document.F1.repassword.value) { alert("retype password is not matching with password. Please re-enter repassword"); document.F1.repassword.value="" document.F1.repassword.focus() return false } if(!isNaN(document.F1.phone.value)) { if(document.F1.phone.value >9999999999 ) { alert("Phone number must be 10 digits long. Please re-enter phone number") document.F1.phone.value="" document.F1.phone.focus() return false } } else { alert("This field must be number") document.F1.phone.value="" document.F1.phone.focus() return false } for(var i=0; i<form.elements.length; i++) { if(form.elements[i].value == "") { alert("Fill out all Fields") form.elements[i].focus() return false } } return true } </SCRIPT>

Page 22: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function ctck1() { var sds = document.getElementById("form"); } </script> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"><h1></h1> </div> </td> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"><h1>CREATE administrator ACCOUNT FORM</h1><br> <table align="center" bgcolor="white">

Page 23: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<tr> </tr> <tr> <td> <form name=F1 onSubmit="return validate(this)" action="registration_servlet" > <table cellspacing="5" cellpadding="3"> <tr><td> NAME:</td><td><input type="text" name="name" /></td></tr> <tr><td>USER NAME:</td><td> <input type="text" name="username"/></td></tr> <tr><td>ADDRESS:</td><td> <input type="text" name="address"/></td></tr> <tr><td>PASSWORD:</td><td> <input type="password" name="password"/></td></tr> <tr><td>RE-PASSWORD:</td><td> <input type="password" name="repassword"/></td></tr> <tr><td>email:</td><td> <input type="text" name="email"/></td></tr> <tr><td>PHONE:</td><td> <input type="text" name="phone"/></td></tr> <tr><td></td><td><input type="submit" value="Submit"/> <INPUT TYPE=RESET VALUE="CLEAR"></td></tr> </table> </form> </td> </tr> </table> </div> </td> <td width="299" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"> <center></center> </div>

Page 24: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

</td> </tr></table> <div id="footer_top"> <div id="footer_navigation"> </div> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> </body> </html> ---------------- ----------- create_acc_admin_res,jsp ------------ -------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css">

Page 25: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

</head> <body> <div id="top_links"> <% String userName = null; String sessionID = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("username")) {userName = cookie.getValue();} }} else {response.sendRedirect("login.jsp");} %> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> <li><a href="create_country_req.jsp">Create Country</a></li> <li><a href="create_product_req.jsp">Create Product</a></li> <li><a href="product_country_link_req.jsp">Link product to country</a></li> <li><a href="edit_profile.jsp">edit account</a></li> <li><a href="logout.jsp">Logout</a></li> </ul> </div> <div id="navigation"> <ul> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;">

Page 26: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> </td> <td width="1200" valign="top"> <h2>welcome. Your account has been created.</h2> <% %> </table> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> ------------ ------------------------ create_acc_err.jsp ------------ --------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html>

Page 27: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> <li><a href="login.jsp">login</a></li> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> </td> <td width="1200" valign="top"> <% %> <table><% int err = (Integer) request.getAttribute("err"); out.print("<table align='left' cellspacing='5' cellpadding='5'>"); if (err==1) {out.print("<tr><td>Incorrect User Name, Password or Account No! Please try again</td></tr>");}

Page 28: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

if (err==2) {out.print("<tr><td>Registration Failed! Please try again</td></tr>");} out.print("</table>"); %></table><% %> </table> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> ----------- ------------------------------------- create_country_req.jsp ---------- ---------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> function validate(form) { for(var i=0; i<2; i++) { if(!isNaN(form.elements[i].value)) { alert("This Field must be in Characters")

Page 29: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

form.elements[i].value="" form.elements[i].focus() return false } } for(var i=2; i<4; i++) { if(isNaN(form.elements[i].value)) { alert("This Field must be in digits") form.elements[i].value="" form.elements[i].focus() return false } } for(var i=0; i<form.elements.length; i++) { if(form.elements[i].value == "") { alert("Fill out all Fields") //document.F1.username.focus() form.elements[i].focus() return false } } return true } </SCRIPT> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function ctck1() { var sds = document.getElementById("form"); } </script> </head> <body>

Page 30: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> <li><a href="create_product_req.jsp">Create Product</a></li> <li>Create counry</li> <li><a href="product_country_link_req.jsp">Link product to country</a></li> <li><a href="edit_profile.jsp">edit account</a></li> <li><a href="logout.jsp">Logout</a></li> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"><h1></h1> </div> </td> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"><h1>CREATE country FORM</h1><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td> <form name=F1 id=F1 onSubmit="return validate(this)" action="create_country_res.jsp" > <table cellspacing="5" cellpadding="3">

Page 31: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<tr><td> Country Name:</td><td><input type="text" name="name" /></td></tr> <tr><td> Currency:</td><td><input type="text" name="currency" /></td></tr> <tr><td> Shipping rate:</td><td><input type="text" name="shipping_rate" /></td></tr> <tr><td> Tax rate:</td><td><input type="text" name="tax_rate" /></td></tr> <tr><td><input type="submit" name = submit value="Submit"/></td> <td><INPUT TYPE=RESET name = reset VALUE="CLEAR"/></td></tr> </table> </form> </td> </tr> </table> </div> </td> <td width="299" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"> <center></center> </div> </td> </tr></table> <div id="footer_top"> <div id="footer_navigation"> </div> <div id="footer_copyright" > <center></center><br> <p></p>

Page 32: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> </body> </html> -------------- ---------------------- create_country_res.jsp ------------ --------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Customer support system</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="top_links"> <% String userName = null; String sessionID = null; Cookie[] cookies = request.getCookies();

Page 33: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("username")) {userName = cookie.getValue();} }} else {response.sendRedirect("login.jsp");} %> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> <li><a href="create_product_req.jsp">Create Product</a></li> <li>Create country</li> <li><a href="product_country_link_req.jsp">Link product to country</a></li> <li><a href="edit_profile.jsp">edit account</a></li> <li><a href="logout.jsp">Logout</a></li> </ul> </div> <div id="navigation"> <ul> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> </td> <td width="1200" valign="top"> <% String name =request.getParameter("name"); String currency =request.getParameter("currency");

Page 34: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

String shipping_rate = request.getParameter("shipping_rate"); Double shipping_int=Double.parseDouble(shipping_rate); String tax_rate = request.getParameter("tax_rate"); Double tax_int=Double.parseDouble(tax_rate); Connection con1=DB_connection.DBConnection(); PreparedStatement ps1=con1.prepareStatement("insert into country values(?,?,?,?,?)"); ps1.setInt(1, DB_connection.getPrimaryKey()); ps1.setString(2,name); ps1.setString(3,currency); ps1.setDouble(4, tax_int); ps1.setDouble(5, shipping_int); ps1.executeUpdate(); out.print("country created successfully"); %> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"><h1>country has been successfully created. </h1><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td> </td> </tr> </table> </div> </td> <table> </table> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided.

Page 35: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> ---------------------- ------------------------ create_product_req.jsp ------------ ---------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> function validate(form) { for(var i=0; i<2; i++) { if(!isNaN(form.elements[i].value)) { alert("This Field must be in Characters") form.elements[i].value="" form.elements[i].focus() return false } } if(document.F1.description.value.length>100) { alert("Please make description up to 100 character long"); document.F1.description.value="" document.F1.description.focus() return false } for(var i=0; i<form.elements.length; i++) { if(form.elements[i].value == "")

Page 36: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

{ alert("Fill out all Fields") //document.F1.username.focus() form.elements[i].focus() return false } } return true } </SCRIPT> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function ctck1() { var sds = document.getElementById("form"); } </script> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> <li><a href="create_country_req.jsp">Create Country</a></li> <li>Create Product</li> <li><a href="product_country_link_req.jsp">Link product to country</a></li> <li><a href="edit_profile.jsp">edit account</a></li> <li><a href="logout.jsp">Logout</a></li>

Page 37: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

</ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"><h1></h1> </div> </td> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"><h1>CREATE product FORM</h1><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td> <form name=F1 id=F1 onSubmit="return validate(this)" action="create_product_res.jsp" > <table cellspacing="5" cellpadding="3"> <tr><td> Product Name:</td><td><input type="text" name="name" /></td></tr> <tr><td> Product Dimensions:</td><td><input type="text" name="dimensions" /></td></tr> <tr><td> Product Weight:</td><td><input type="text" name="weight" /></td></tr> <tr><td> Product Manufacturer:</td><td><input type="text" name="manufacturer" /></td></tr> <!-- <tr><td>Dimensions:</td><td> <input type="textarea" name="description" style="height: 92px; "/></td></tr> --> <tr><td>Description:</td><td><textarea name="description" form="F1">Enter text here...</textarea> <tr><td><input type="submit" name = submit value="Submit"/></td>

Page 38: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<td><INPUT TYPE=RESET name = reset VALUE="CLEAR"/></td></tr> </table> </form> </td> </tr> </table> </div> </td> <td width="299" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"> <center></center> </div> </td> </tr></table> <div id="footer_top"> <div id="footer_navigation"> </div> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> <%@ page import="java.sql.*"%>

Page 39: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> </body> </html> --------------- ------------------- create_product_res.jsp ------------ ----------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="top_links"> <% String userName = null; String sessionID = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("username")) {userName = cookie.getValue();} }} else {response.sendRedirect("login.jsp");} %> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2>

Page 40: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

</div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> <li><a href="create_country_req.jsp">Create Country</a></li> <li>Create Product</li> <li><a href="product_country_link_req.jsp">Link product to country</a></li> <li><a href="edit_profile.jsp">edit account</a></li> <li><a href="logout.jsp">Logout</a></li> </ul> </div> <div id="navigation"> <ul> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <% String name =request.getParameter("name"); String dimensions =request.getParameter("dimensions"); String weight = request.getParameter("weight"); double weight_int=Double.parseDouble(weight); String manufacturer = request.getParameter("manufacturer"); String description = request.getParameter("description"); Connection con1=DB_connection.DBConnection(); PreparedStatement ps1=con1.prepareStatement("insert into product values(?,?,?,?,?,?)"); ps1.setInt(1, DB_connection.getPrimaryKey()); ps1.setString(2,name); ps1.setString(3,dimensions); ps1.setString(4,manufacturer); ps1.setString(5,description); ps1.setDouble(6,weight_int); ps1.executeUpdate();

Page 41: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

out.print("product created successfully"); %> </td> <td width="1200" valign="top"> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"><h1>product has been successfully created. </h1><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td> </td> </tr> </table> </div> </td> <table> </table> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> ------------- --------------------------------

Page 42: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

edit_profile.jsp ------------ ------------ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> function validate(form) { for(var i=1; i<3; i++) { if(!isNaN(form.elements[i].value)) { alert("This Field must be in Characters") form.elements[i].value="" form.elements[i].focus() return false } } if(document.F1.password.value!=document.F1.repassword.value) { alert("retype password is not matching with password. Please re-enter repassword"); document.F1.repassword.value="" document.F1.repassword.focus() return false } if(!isNaN(document.F1.phone.value)) { if(document.F1.phone.value >9999999999 ) { alert("Phone number must be 10 digits long. Please re-enter phone number") document.F1.phone.value="" document.F1.phone.focus() return false } } else { alert("This field must be number") document.F1.phone.value="" document.F1.phone.focus()

Page 43: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

return false } for(var i=0; i<form.elements.length; i++) { if(form.elements[i].value == "") { alert("Fill out all Fields") form.elements[i].focus() return false } } return true } </SCRIPT> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function ctck1() { var sds = document.getElementById("form"); } </script> </head> <body> <div id="top_links"> <% %> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2>

Page 44: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

</div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> <li><a href="login.jsp">Login</a></li> <li><a href="logout.jsp">Log out</a></li> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"><h1></h1> </div> </td> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"><h1>Edit profile</h1><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td> <form name=F1 onSubmit="return validate(this)" action="updated_profile.jsp" > <table cellspacing="5" cellpadding="3"> <% try { String userName = null; String sessionID = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("username")) {userName = cookie.getValue();}

Page 45: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

}} else {response.sendRedirect("login.jsp");} Connection con = DB_connection.DBConnection(); PreparedStatement ps=con.prepareStatement("Select * from user_table where username ='"+userName+"'"); System.out.print (userName); ResultSet rs=ps.executeQuery(); while(rs.next()){ %> <tr><td> <input type="hidden" name="no" value ="<%=rs.getInt(1)%>"></td></tr> <tr><td> NAME:</td><td><input type="text" name="name" value ="<%=rs.getString(2)%>"/></td></tr> <tr><td>USER NAME:</td><td> <input type="text" name="username" value ="<%=rs.getString(3)%>"></td></tr> <tr><td>ADDRESS:</td><td> <input type="text" name="address"value ="<%=rs.getString(4)%>"></td></tr> <tr><td>PASSWORD:</td><td> <input type="password" name="password"value ="<%=rs.getString(5)%>"></td></tr> <tr><td>RE-PASSWORD:</td><td> <input type="password" name="repassword"value ="<%=rs.getString(6)%>"></td></tr> <tr><td>email:</td><td> <input type="text" name="email"value ="<%=rs.getString(7)%>"></td></tr> <tr><td>PHONE:</td><td> <input type="text" name="phone"value ="<%=rs.getInt(8)%>"></td></tr> <tr><td> <input type="hidden" name="usertype" value ="<%=rs.getString(9)%>"></td></tr> <tr><td></td><td><input type="submit" value="Submit"/> <INPUT TYPE=RESET VALUE="CLEAR"></td></tr> <% } } catch (SQLException e) { e.printStackTrace(); } %>

Page 46: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

</table> </form> </td> </tr> </table> </div> </td> <td width="299" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"> <center></center> </div> </td> </tr></table> <div id="footer_top"> <div id="footer_navigation"> </div> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%>

Page 47: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<%@ page import="store.*" %> </body> </html> ---------------- -------------- index.jsp --------- ------------ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function ctck() { var sds = document.getElementById("form"); } </script> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store system</h2> </div> <div id="navigation"> <form name=F1 onSubmit="return check(this)" action="search_product_req.jsp" > <table cellspacing="5" cellpadding="3"> <tr><td>Select country</td><td> <select name="country" id="country">

Page 48: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<option value="-1">--- Select ---</option> <% Connection con=DB_connection.DBConnection(); String open_status = "o"; PreparedStatement ps=con.prepareStatement("Select * from country"); ResultSet rs=ps.executeQuery(); while (rs.next()) { %> <option value="<% out.print(rs.getInt(1)); %>"><% out.print(rs.getString(2)); %></option> <% } %> <% %> </select> </td></tr> <tr><td></td><td> <input type="submit" value="Submit"></table> </form> </div> <table style="width:97px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="100" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"> <p>PLEASE CHOOSE YOUR COUNTRY.</p><br> </div> </td> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"> <table align="center" bgcolor="white"> <tr> <P>Welcome to the online store of Waltech Inc. </P>

Page 49: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<P>We have the best hardware tools and accessories for the timber industry. We have a sale policy where we will resolve your issues related to sales within 24 hours. </P> <P>You can send email to [email protected]</P> </tr> <tr> </tr> </td> </tr> </table> </div> </td> <td width="9" valign="top"> </td> </tr></table> <div id="footer_top"> <div id="footer_navigation"> </div> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %>

Page 50: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> </body> </html> --------------------- -------------- login.jsp --------- -------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> function check(form) { for(var i=0; i<form.elements.length; i++) { if(form.elements[i].value == "") { alert("Fill out all Fields") form.elements[i].focus() return false } } if(document.F1.usertype.value=="-1") { alert("Please select usertype") document.F1.usertype.focus() return false } if(!isNaN(document.F1.username.value)) { alert("User Name must be characters & can't be null") document.F1.username.value="" document.F1.username.focus() return false } if(document.F1.password.value!=document.F1.repassword.value) {

Page 51: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

alert("Password and reapssword must match") document.F1.repassword.value="" document.F1.repassword.focus() return false } return true } </SCRIPT> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function ctck() { var sds = document.getElementById("form"); } </script> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to the Multinational Online Store</h2> </div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> </ul> </div> <h3>Hi, Please login.</h3> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr >

Page 52: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<td width="300" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"><ul> </ul> </div> </td> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"><h1>Login</h1><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td><div></div> <form name=F1 onSubmit="return check(this)" action="login_servlet" > <table cellspacing="5" cellpadding="3"> <tr><td>USER NAME:</td><td> <input type="text" name="username"/></td></tr> <tr><td>PASSWORD:</td><td> <input type="password" name="password"/></td></tr> <tr><td>REPASSWORD:</td><td> <input type="password" name="repassword"/></td></tr> <tr><td><input type="submit" value="Submit"></td><td> <INPUT TYPE=RESET VALUE="CLEAR"></td></tr> </table> </form> </td> </tr> </table> </div> </td> <td width="299" valign="top"> </td>

Page 53: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

</tr></table> <div id="footer_top"> <div id="footer_navigation"> </div> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> </body> </html> ----------- -------------- logout.jsp -------- ---------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> function check(form) { for(var i=0; i<form.elements.length; i++) { if(form.elements[i].value == "") {

Page 54: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

alert("Fill out all Fields") form.elements[i].focus() return false } } if(document.F1.usertype.value=="-1") { alert("Please select usertype") document.F1.usertype.focus() return false } if(!isNaN(document.F1.username.value)) { alert("User Name must be characters & can't be null") document.F1.username.value="" document.F1.username.focus() return false } if(!isNaN(document.F1.password.value)) { alert("Password must be characters & can't be null") document.F1.password.value="" document.F1.password.focus() return false } return true } </SCRIPT> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function ctck() { var sds = document.getElementById("form"); } </script> </head>

Page 55: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to the Multinational Online Store</h2> </div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> </ul> </div> <% //allow access only if session exists String userName = null; String sessionID = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("username")) userName = cookie.getValue(); cookie.setMaxAge(0); } } %> <h3>Hi <%=userName %>, You have successfully logged out. Please log in to continue.</h3> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"><ul> </ul> </div> </td> <td width="1200" valign="top">

Page 56: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<div id="welcome" style="border-right:#666666 1px dotted;"><h1>LOGIN FORM</h1><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td><div></div> <form name=F1 onSubmit="return check(this)" action="login_servlet" > <table cellspacing="5" cellpadding="3"> <tr><td>USER NAME:</td><td> <input type="text" name="username"/></td></tr> <tr><td>PASSWORD:</td><td> <input type="password" name="password"/></td></tr> <tr><td>REPASSWORD:</td><td> <input type="password" name="repassword"/></td></tr> <tr><td><input type="submit" value="Submit"></td><td> <INPUT TYPE=RESET VALUE="CLEAR"></td></tr> </table> </form> </td> </tr> </table> </div> </td> <td width="299" valign="top"> </td> </tr></table> <div id="footer_top"> <div id="footer_navigation"> </div> <div id="footer_copyright" >

Page 57: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> </body> </html> ------------ --------------------- pay_req.jsp ------- ------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> function validate(form) { if(document.F1.card_type.value.length>1) { alert("Card type should be either 'V' or 'M'. "); document.F1.card_type.value="" document.F1.card_type.focus() return false } if(document.F1.expiry_date.value != '' && !document.F1.expiry_date.value.match(/^\d{1,2}\/\d{1,2}\/\d{4}$/)) { alert("Please provide a valid date in format MM/DD/YYYY");

Page 58: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

document.F1.expiry_date.value="" document.F1.expiry_date.focus() return false } for(var i=0; i<form.elements.length; i++) { if(form.elements[i].value == "") { alert("Fill out all Fields") //document.F1.username.focus() form.elements[i].focus() return false } } return true } </SCRIPT> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function ctck1() { var sds = document.getElementById("form"); } </script> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div>

Page 59: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<div id="navigation"> </div> <% String country = null; String countryID = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("countryID")) {countryID = cookie.getValue();} }} else {response.sendRedirect("index.jsp");} Connection con=DB_connection.DBConnection(); int country_ID1=Integer.parseInt(countryID); PreparedStatement ps=con.prepareStatement("Select name from country where no =?"); ps.setInt(1, country_ID1); ResultSet rs=ps.executeQuery(); out.print("<table align='left' cellspacing='5' cellpadding='5'>"); while (rs.next()){ out.print("<tr><td><b>" + rs.getString(1) + " </b>Country site.</td></tr>");} out.print("</table"); %><% String product = null; String productID = null; Cookie[] cookies1 = request.getCookies(); if(cookies1 !=null){ for(Cookie cookie : cookies1){ if(cookie.getName().equals("productID")) {productID = cookie.getValue();} }} else {response.sendRedirect("index.jsp");} %> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"><h1></h1>

Page 60: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

</div> </td> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"><h1>Pay for your purchase</h1><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td> <form name=F1 id=F1 onSubmit="return validate(this)" action="pay_res.jsp" > <table cellspacing="5" cellpadding="3"> <% String amount = null; int amount_int=0; Cookie[] cookies2 = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("total_amount")) {amount = cookie.getValue();} }} //amount_int=Integer.parseInt(amount); %> <tr><td> Amount to be paid:</td><td><input type="text" name="total_amount" value ="<%=amount%>" readonly/></td></tr> <tr><td> Card type (V for Visa, M for Mastercard):</td><td><input type="text" name="card_type" /></td></tr> <tr><td> Card Number:</td><td><input type="text" name="card_number" /></td></tr> <tr><td> Name on card:</td><td><input type="text" name="name_on_card" /></td></tr> <tr><td>Expiry date (MM/DD/YYYY):</td><td> <input type="text" name="expiry_date"/></td></tr>

Page 61: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<tr><td><input type="submit" name = submit value="Submit"/></td> <td><INPUT TYPE=RESET name = reset VALUE="CLEAR"/></td></tr> <% %> </table> </form> </td> </tr> </table> </div> </td> <td width="299" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"> <center></center> </div> </td> </tr></table> <div id="footer_top"> <div id="footer_navigation"> </div> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided.

Page 62: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> </body> </html> ------- ---------------------- pay_res.jsp -------- ------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> </div> <div id="navigation">

Page 63: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<ul> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <% String country = null; int country_int= 0; String countryID1 = ""; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("countryID")) {countryID1 = cookie.getValue();} } } else {response.sendRedirect("index.jsp");} country_int= Integer.parseInt(countryID1); Connection con=DB_connection.DBConnection(); PreparedStatement ps=con.prepareStatement("Select name from country where no =?"); ps.setInt(1, country_int); ResultSet rs=ps.executeQuery(); out.print("<table align='left' cellspacing='5' cellpadding='5'>"); while (rs.next()){ out.print("<tr><td><b>" + rs.getString(1) + " </b>Country site.</td></tr>");} out.print("</table"); String product = null; String productID = null; Cookie[] cookies1 = request.getCookies(); if(cookies1 !=null){ for(Cookie cookie : cookies1){ if(cookie.getName().equals("productID")) {productID = cookie.getValue();} }}

Page 64: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

else {response.sendRedirect("index.jsp");} int productID_int= Integer.parseInt(productID); %> <% try { String product_qty = null; int product_qty_int=0; Cookie[] cookies2 = request.getCookies(); if(cookies2 !=null){ for(Cookie cookie : cookies2){ if(cookie.getName().equals("product_qty")) {product_qty = cookie.getValue();} }} else {response.sendRedirect("index.jsp");} product_qty_int=Integer.parseInt(product_qty); String buyer_string = null; int buyer_int=0; Cookie[] cookies3 = request.getCookies(); if(cookies3 !=null){ for(Cookie cookie : cookies3){ if(cookie.getName().equals("buyerID")) {buyer_string = cookie.getValue();} }} buyer_int=Integer.parseInt(buyer_string); String amount = null; double amount_int=0; Cookie[] cookies4 = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("total_amount")) {amount = cookie.getValue();} }} amount_int=Double.parseDouble(amount); String card_type =request.getParameter("card_type"); String card_number = request.getParameter("card_number"); int card_number_int=Integer.parseInt(card_number); String name_on_card = request.getParameter("name_on_card"); String expiry_date = request.getParameter("expiry_date");

Page 65: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

Connection con1=DB_connection.DBConnection(); PreparedStatement ps1=con1.prepareStatement("update buyer set card_type=?,card_number=?,name_on_card=?,expiry_date=? where no=?"); ps1.setString(1, card_type); ps1.setInt(2,card_number_int); ps1.setString(3,name_on_card); ps1.setString(4,expiry_date); ps1.setInt(5,buyer_int); ps1.executeUpdate(); Double shipping_charge=0.00; Double tax_charge=0.00; String currency=null; Connection con2=DB_connection.DBConnection(); PreparedStatement ps2=con2.prepareStatement("select tax_rate, shipping_rate, currency from country where no=?"); ps2.setInt(1, country_int); ResultSet rs2=ps2.executeQuery(); while(rs2.next()){ shipping_charge = rs2.getDouble(2); tax_charge = rs2.getDouble(1); currency = rs2.getString(3); } String product_name=null; Connection con3=DB_connection.DBConnection(); PreparedStatement ps3=con3.prepareStatement("select name from product where no=?"); ps3.setInt(1, productID_int); ResultSet rs3=ps3.executeQuery(); while(rs3.next()){ product_name = rs3.getString(1); } Connection con4=DB_connection.DBConnection(); PreparedStatement ps4=con4.prepareStatement("insert into purchase values(?,?,?,?,?,?,?,?,?)"); ps4.setInt(1, DB_connection.getPrimaryKey()); ps4.setInt(2,buyer_int); ps4.setInt(3,productID_int);

Page 66: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

ps4.setInt(4,product_qty_int); ps4.setDate(5,new java.sql.Date(new java.util.Date().getTime())); ps4.setInt(6,country_int); ps4.setDouble(7,tax_charge); ps4.setDouble(8,shipping_charge); ps4.setDouble(9,amount_int); ps4.executeUpdate(); ps4.close(); out.print("<tr><th>Thanks for purchasing from Waltech Inc. Your product "+product_name+ " is ready to be shipped. You have paid "+ currency +amount_int+". Once your product is shipped we will send your tracking number on your registered email ID.</th></tr>"); } catch (SQLException e) { e.printStackTrace(); } %></table> <tr> </tr> <table> </table> <div id="footer_copyright" > <center></center><br> <p></p>

Page 67: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> ------------- ----------------------- product_country_link_req.jsp ----------- ---------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> function validate(form) { for(var i=0; i<form.elements.length; i++) { if(form.elements[i].value == "") { alert("Fill out all Fields") //document.F1.username.focus() form.elements[i].focus() return false } } return true } </SCRIPT> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title>

Page 68: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function ctck1() { var sds = document.getElementById("form"); } </script> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> <li><a href="create_product_req.jsp">Create Product</a></li> <li>Create country</li> <li><a href="product_country_link_req.jsp">Link product to country</a></li> <li><a href="edit_profile.jsp">edit account</a></li> <li><a href="logout.jsp">Logout</a></li> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"><h1></h1> <% String userName = null; String sessionID = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("username")) {userName = cookie.getValue();}

Page 69: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

}} //else {response.sendRedirect("login.jsp");} %> </div> </td> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"><h1>CREATE country product link FORM</h1><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td> <form name=F1 id=F1 onSubmit="return validate(this)" action="product_country_link_res.jsp" > <table cellspacing="5" cellpadding="3"> <tr><td><select name="product" id="title"><option value="">--- Select --- </option> <% Connection con=DB_connection.DBConnection(); PreparedStatement ps=con.prepareStatement("Select * from product "); //ps.setString(1, userName); ResultSet rs=ps.executeQuery(); while (rs.next()) { %> <option value="<% out.print(rs.getInt(1)); %>"><% out.print(rs.getString(2)); %></option> <% } %> </select> </td></tr> <tr><td><select name="country" id="country"><option value="">--- Select --- </option> <% Connection con1=DB_connection.DBConnection(); PreparedStatement ps1=con.prepareStatement("Select * from country "); //ps.setString(1, userName);

Page 70: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

ResultSet rs1=ps1.executeQuery(); while (rs1.next()) { %> <option value="<% out.print(rs1.getInt(1)); %>"><% out.print(rs1.getString(2)); %></option> <% } %> </select> </td></tr> <tr><td> Set Price:</td><td><input type="text" name="price" /></td></tr> <tr><td><input type="submit" name = submit value="Submit"/></td> <td><INPUT TYPE=RESET name = reset VALUE="CLEAR"/></td></tr> </table> </form> </td> </tr> </table> </div> </td> <td width="299" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"> <center></center> </div> </td> </tr></table> <div id="footer_top"> <div id="footer_navigation"> </div>

Page 71: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> </body> </html> ------------ --------------------- product_country_link_res.jsp ------------- -------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="top_links"> <%

Page 72: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

String userName = null; String sessionID = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("username")) {userName = cookie.getValue();} }} else {response.sendRedirect("login.jsp");} %> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> <li><a href="create_product_req.jsp">Create Product</a></li> <li>Create country</li> <li><a href="product_country_link_req.jsp">Link product to country</a></li> <li><a href="edit_profile.jsp">edit account</a></li> <li><a href="logout.jsp">Logout</a></li> </ul> </div> <div id="navigation"> <ul> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <% String product =request.getParameter("product"); int product_int=Integer.parseInt(product);

Page 73: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

String country =request.getParameter("country"); int country_int=Integer.parseInt(country); String price = request.getParameter("price"); Double price_int=Double.parseDouble(price); Double product_price=0.00; Connection con=DB_connection.DBConnection(); PreparedStatement ps=con.prepareStatement("select product_price from product_country where country_no=? and product_no=?"); ps.setInt(1, country_int); ps.setInt(2, product_int); ResultSet rs=ps.executeQuery(); while(rs.next()){ product_price = rs.getDouble(1); } if (product_price==0.00){ Connection con1=DB_connection.DBConnection(); PreparedStatement ps1=con1.prepareStatement("insert into product_country values(?,?,?,?)"); ps1.setInt(1, DB_connection.getPrimaryKey()); ps1.setInt(2, country_int); ps1.setInt(3, product_int); ps1.setDouble(4, price_int); ps1.executeUpdate(); out.print("product is successfully linked to country"); } else{ Connection con2=DB_connection.DBConnection(); PreparedStatement ps2; ps2 = con2.prepareStatement("Update product_country set product_price=? where product_no=? and country_no=?"); ps2.setDouble(1, price_int); ps2.setInt(2,product_int); ps2.setInt(3,country_int); ps.executeUpdate(); System.out.println(price_int); out.print("product price is successfully updated");

Page 74: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

} %> </td> </tr> </table> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> ---------- ------------------------------------- search_product_req.jsp ------------- ---------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> function validate(form) { for(var i=0; i<form.elements.length; i++) { if(form.elements[i].value == "") { alert("Fill out all Fields") form.elements[i].focus() return false }

Page 75: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

} return true } </SCRIPT> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function ctck1() { var sds = document.getElementById("form"); } </script> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> <% String country_ID =request.getParameter("country"); int country_ID1=Integer.parseInt(country_ID); Cookie countryID = new Cookie("countryID", country_ID); countryID.setMaxAge(30*60); response.addCookie(countryID); Connection con=DB_connection.DBConnection(); String country = ""; PreparedStatement ps=con.prepareStatement("Select name from country where no =?"); ps.setInt(1, country_ID1); ResultSet rs=ps.executeQuery(); out.print("<table align='left' cellspacing='5' cellpadding='5'>");

Page 76: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

while (rs.next()){ out.print("<tr><td><b>" + rs.getString(1) + " </b>Country site.</td></tr>");} out.print("</table"); %> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"><h1></h1> </div> </td> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"><h1>Search product</h1><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td> <form name=F1 onSubmit="return validate(this)" action="search_product_res.jsp" > <table cellspacing="5" cellpadding="3"> <tr><td> Product Name:</td><td><input type="text" name="product_name" /></td></tr> <tr><td></td><td><input type="submit" value="Submit"/> <INPUT TYPE=RESET VALUE="CLEAR"></td></tr> </table> </form> </td> </tr>

Page 77: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

</table> </div> </td> <td width="299" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"> <center></center> </div> </td> </tr></table> <div id="footer_top"> <div id="footer_navigation"> </div> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> </body> </html>

Page 78: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

------------- -------------------- search_product_res.jsp ------------- ------------ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> </div> <div id="navigation"> <ul> </ul> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> </td> <td width="1200" valign="top">

Page 79: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<table> <% String country = null; int country_int= 0; String countryID = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("countryID")) {countryID = cookie.getValue();} } country_int= Integer.parseInt(countryID);} else {response.sendRedirect("index.jsp");} Connection con=DB_connection.DBConnection(); PreparedStatement ps=con.prepareStatement("Select name from country where no =?"); ps.setInt(1, country_int); ResultSet rs=ps.executeQuery(); out.print("<table align='left' cellspacing='5' cellpadding='5'>"); while (rs.next()){ out.print("<tr><td><b>" + rs.getString(1) + " </b>Country site.</td></tr>");} out.print("</table"); %> <% try{ String search_product =request.getParameter("product_name"); Connection con1=DB_connection.DBConnection(); //PreparedStatement ps=con.prepareStatement("select product_no from product_country where country_no= "+countryID +"and product_no in (select no from product where name like %"+search_product+")" ); PreparedStatement ps1=con1.prepareStatement("select * from product where no in (select product_no from product_country where country_no="+country_int+") and name like '%"+search_product+"%'"); ResultSet rs1=ps1.executeQuery(); out.print("<table align='left' cellspacing='5' cellpadding='5'>"); out.print("<tr><th>PRODUCT NAME</th><th>MANUFACTURER NAME</th><th>DIMENSIONS</th><th>DESCRIPTION</th></tr>"); int product_no=0; while(rs1.next()){

Page 80: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

out.print("<tr>"); out.print("<td> <a href=view_product_detail_res.jsp?no="+rs1.getString(2)+">"+rs1.getString(2)+"</a></td>"); product_no=rs1.getInt(1); String product_string=Integer.toString(product_no); Cookie productID = new Cookie("productID", product_string); productID.setMaxAge(30*60); response.addCookie(productID); out.print("<td>" + rs1.getString(4) + "</td>"); out.print("<td>" + rs1.getString(3) + "</td>"); out.print("<td>" + rs1.getString(5) + "</td>"); out.print("</tr>"); } out.print("</table>"); } catch (SQLException e) { e.printStackTrace(); } finally{}; %> </table> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %>

Page 81: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> -------------- ------------------------ updated_profile.jsp ------------ ---------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function ctck1() { var sds = document.getElementById("form"); } </script> </head> <body> <div id="top_links"> <% %> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> <ul> <li><a href="index.jsp">Home</a></li> <li><a href="edit_acc.jsp">edit account</a></li>

Page 82: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<li><a href="logout.jsp">Logout</a></li> </ul> <% String userName = null; String sessionID = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("username")) {userName = cookie.getValue(); } }} else {response.sendRedirect("login.jsp");} %> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <div id="services"><h1></h1> </div> </td> <td width="1200" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"><h3></h3><br> <table align="center" bgcolor="white"> <tr> </tr> <tr> <td> <% String no = request.getParameter("no"); int ano = Integer.parseInt(no); System.out.println(ano); String name=request.getParameter("name"); String username=request.getParameter("username"); String address=request.getParameter("address"); String password=request.getParameter("password"); String repassword=request.getParameter("repassword"); String email=request.getParameter("email"); String phone=request.getParameter("phone"); double ph = Double.parseDouble(phone);

Page 83: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

String usertype2=request.getParameter("usertype"); //char usertype3=usertype.charAt(0); int status; Connection con=DB_connection.DBConnection(); PreparedStatement ps; try { ps = con.prepareStatement("Update user_table set no=?, name =?, username= ?, address=?, password=?,repassword=?,email=?,phone=?,usertype=? where no="+ano); ps.setInt(1, ano); ps.setString(2,name); ps.setString(3,username); ps.setString(4,address); ps.setString(5,password); ps.setString(6,repassword); ps.setString(7,email); ps.setDouble(8,ph); ps.setString(9,usertype2); status=ps.executeUpdate(); System.out.println(address); } catch (SQLException e) { e.printStackTrace(); } finally {}; //status=register_user.update(ano, name, username, address, password, repassword, email, ph, usertype); //if (status ==1){ out.print("Profile updated successfully"); %> <table cellspacing="5" cellpadding="3"> </td> </tr> </table> </div>

Page 84: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

</td> <td width="299" valign="top"> <div id="welcome" style="border-right:#666666 1px dotted;"> <center></center> </div> </td> </tr></table> <div id="footer_top"> <div id="footer_navigation"> </div> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div> <script type="text/javascript"> document.onload = ctck(); </script> </div> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %> </body> </html> -------------- --------------------

Page 85: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

view_product_detail_res.jsp ------------ -------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Multinational Online Store</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="top_links"> <div id="header"> <h1>Multinational Online Store<span class="style1"></span></h1> <h2>Welcome to Multinational Online Store</h2> </div> <div id="navigation"> </div> <table style="width:897px; background:#FFFFFF; margin:0 auto;"> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> </td> <td width="1200" valign="top"> <% String countryID1 = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){

Page 86: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

if(cookie.getName().equals("countryID")) {countryID1 = cookie.getValue();} }} else {response.sendRedirect("login.jsp");} Connection con=DB_connection.DBConnection(); String country = ""; int country_int=Integer.parseInt(countryID1); PreparedStatement ps=con.prepareStatement("Select name from country where no =?"); ps.setInt(1, country_int); ResultSet rs=ps.executeQuery(); out.print("<table align='left' cellspacing='5' cellpadding='5'>"); while (rs.next()){ out.print("<tr><td><b>" + rs.getString(1) + " </b>Country site.</td></tr>");} out.print("</table"); %> <table> <% try { String productID1 = null; Cookie[] cookies1 = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("productID")) {productID1 = cookie.getValue();} }} else {response.sendRedirect("login.jsp");} int product_int=Integer.parseInt(productID1); Connection con1 = DB_connection.DBConnection(); PreparedStatement ps1=con1.prepareStatement("Select * from product where no=?"); ps1.setInt(1, product_int); ResultSet rs1=ps1.executeQuery(); out.print("<table align='left' cellspacing='5' cellpadding='5'>"); out.print("<br><br><tr><th>NAME</th><th>DIMENSION</th><th>MANUFACTURER</th><th>DESCRIPTION</th></tr>");

Page 87: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

while(rs1.next()){ out.print("<tr><th>"+rs1.getString(2)+"</th>"); out.print("<th>"+rs1.getString(3)+"</th>"); out.print("<th>"+rs1.getString(4)+"</th>"); out.print("<th>"+rs1.getString(5)+"</th></tr>"); String product_name1=rs1.getString(2); Cookie product = new Cookie("product", product_name1); product.setMaxAge(30*60); response.addCookie(product); String product_dimension1=rs1.getString(3); Cookie product_dimension = new Cookie("dimension", product_dimension1); product_dimension.setMaxAge(30*60); response.addCookie(product_dimension); } out.print("</table>"); } catch (SQLException e) { e.printStackTrace(); } %></table><% %> <tr > <td width="300" valign="top" style="border-right:#666666 1px dotted;"> <a href="buy_req.jsp"><h1 >Buy</h1 ></a> </td> </tr > </table> <div id="footer_copyright" > <center></center><br> <p></p> Conceived, Designed & Developed by Ashfaque Ahmed. Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at <a href=mailto:[email protected]>[email protected]</a></div> </div>

Page 88: Complimentary material for the book “Software Engineering ...€¦ · Complimentary material for the book “Software Engineering in the Agile World” (ISBN: 978-93-5300-898-7)

Copyright material Distributed under Creative Commons CC-BY 2.0 license. You can use the material for education purpose freely if attribution of source of the material is provided. For commercial inquiries please contact Ashfaque Ahmed at [email protected]. Do not duplicate and do not give it to any other person or entity.

<%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*"%> <%@ page import="store.*" %>