Complimentary material for the book Software Engineering in the Agile World

Similar documents
Author - Ashfaque Ahmed

CreateServlet.java

CREATE A SERVLET PROGRAM TO DISPLAY THE STUDENTS MARKS. To create a servlet program to display the students marks

ServletConfig Interface

Kamnoetvidya Science Academy. Object Oriented Programming using Java. Ferdin Joe John Joseph. Java Session

Advanced Internet Technology Lab # 4 Servlets

Develop an Enterprise Java Bean for Banking Operations

To create a view for students, staffs and courses in your departments using servlet/jsp.

Université Antonine - Baabda

Unit-4: Servlet Sessions:

CIS 3952 [Part 2] Java Servlets and JSP tutorial

J2ME With Database Connection Program

Servlet 5.1 JDBC 5.2 JDBC

JAVA SERVLET. Server-side Programming INTRODUCTION

Servlets by Example. Joe Howse 7 June 2011

SQream Connector JDBC SQream Technologies Version 2.9.3

Author - Ashfaque Ahmed

Assignment -3 Source Code. Student.java

// Static initializer block to load the JDBC Driver static {

An implementation of Tree Panel component in EXT JS 4.0

WEB SERVICES EXAMPLE 2

&' () - #-& -#-!& 2 - % (3" 3 !!! + #%!%,)& ! "# * +,

Servlet. 1.1 Web. 1.2 Servlet. HTML CGI Common Gateway Interface Web CGI CGI. Java Applet JavaScript Web. Java CGI Servlet. Java. Apache Tomcat Jetty

JAVA SERVLET. Server-side Programming ADVANCED FEATURES

Getting started with Winstone. Minimal servlet container

JdbcResultSet.java. import java.sql.*;

INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M 1.B HTML FORM CREATION - 2 M

Scheme G Sample Question Paper Unit Test 2

Fraud Detection And Integrity Of Database Without Using Pl-SQL Logic

Accessing EJB in Web applications

Backend. (Very) Simple server examples

SWE642 Oct. 22, 2003

Penetration: from application down to OS

EJB - ACCESS DATABASE

AJP. CHAPTER 5: SERVLET -20 marks

Trusted Source SSO. Document version 2.3 Last updated: 30/10/2017.

JSP. Common patterns

Preview from Notesale.co.uk Page 6 of 132

Advanced Web Technology

Web based Applications, Tomcat and Servlets - Lab 3 -

Programming a Bank Database. We ll store the information in two tables: INTEGER DECIMAL(10, 2)

Servlets Pearson Education, Inc. All rights reserved.

DEZVOLTAREA APLICATIILOR WEB CURS 7. Lect. Univ. Dr. Mihai Stancu

Servlet Basics. Agenda

Appendix: Assorted Sweets

1. PhP Project. Create a new PhP Project as shown below and click next

WHITE LABELING IN PROGRESS ROLLBASE PRIVATE CLOUD

Algorithmic Verification of Procedural Programs in the Presence of Code Variability

PARTIAL Final Exam Reference Packet

Jawaharlal Nehru Engineering College

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Servlet. Web Server. Servlets are modules of Java code that run in web server. Internet Explorer. Servlet. Fire Fox. Servlet.

Integrate JPEGCAM with WaveMaker

Distributed Systems Project 5 Assigned: Friday, April 6, 2012 Due: Friday, April 20, 11:59:59 PM

OCP JavaEE 6 EJB Developer Study Notes

Handout 31 Web Design & Development

A.1 JSP A.2 JSP JSP JSP. MyDate.jsp page contenttype="text/html; charset=windows-31j" import="java.util.calendar" %>

HTTP status codes. Setting status of an HTTPServletResponse

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige

JavaServer Pages (JSP)

Accessing databases in Java using JDBC

EXPERIMENT- 9. Login.html

JAVA SERVLET. Server-side Programming PROGRAMMING

Online Book Services

Introduction to Servlets. After which you will doget it

CSC309: Introduction to Web Programming. Lecture 10

sessionx Desarrollo de Aplicaciones en Red A few more words about CGI CGI Servlet & JSP José Rafael Rojano Cáceres

Principles and Techniques of DBMS 6 JSP & Servlet

JDBC [Java DataBase Connectivity]

( A ) 8. If the address of an array is stored in $value, how do you get the values of this array? (B) \$value (C) &$value (D) $$value

2. Follow the installation directions and install the server on ccc. 3. We will call the root of your installation as $TOMCAT_DIR

[I] SLT Operations & Maintenance (2009), OSP Maintenance Report, Annual Maintenance Report of Sri Lanka Telecom PLC, 4(3), pp 43-51

Server-side Web Programming

CSE 530A. DAOs and MVC. Washington University Fall 2012

UNIVERSITY OF MUMBAI. Teacher s Reference Manual. Subject: Enterprise Java

Handling Cookies. Agenda

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22.

Generating the Server Response: HTTP Status Codes

Connection Pools. The ConnectionObject

Allenhouse Institute of Technology (UPTU Code : 505) OOT Notes By Hammad Lari for B.Tech CSE V th Sem

Stateless -Session Bean

Lab session Google Application Engine - GAE. Navid Nikaein

Prof. Edwar Saliba Júnior

Strut2 jasper report plugin - War deployment

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http?

Get the cookies from the service request: Cookie[] HttpServletRequest.getCookies() Add a cookie to the service response:

3. The pool should be added now. You can start Weblogic server and see if there s any error message.

Advanced Topics in Operating Systems. Manual for Lab Practices. Enterprise JavaBeans

Advanced Internet Technology Lab # 6

Introduction to Server-Side Technologies

SDN Community Contribution

To follow the Deitel publishing program, sign-up now for the DEITEL BUZZ ON-

May 13, 2015 [MSDP SERVICES INTEGRATION DOCUMENT VER 1.4] Page 1 of 23

Distributed Computing

Servlets. An extension of a web server runs inside a servlet container

SERVLET AND JSP FILTERS

Module 4: SERVLET and JSP

Welcome to Ruby. Yehuda Katz. Engine Yard

Demonstration of Servlet, JSP with Tomcat, JavaDB in NetBeans

Transcription:

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

Multinational online store project Class files DB_connection.java --- --- -------- --------- import java.sql.*; import java.io.*; public class DB_connection { private DB_connection(){ public static Connection con; static{ Class.forName(DB_initialize.DRIVER); con=drivermanager.getconnection(db_initialize.con_string,db_initialize. USERNAME,DB_initialize.PASSWORD); catch (ClassNotFoundException e) { catch (SQLException e) { System.out.println("Exception in GetCon"); public static Connection DBConnection(){ return con; public static int getprimarykey(){ int nextvalue=0; Connection con=db_connection.dbconnection(); PreparedStatement ps2; ps2=con.preparestatement("select store_seq.nextval from dual"); ResultSet rs=ps2.executequery(); rs.next(); nextvalue=rs.getint(1);

System.out.println(nextvalue); catch (SQLException e) { return nextvalue; DB_initialize.java --------- ----------- - public interface DB_initialize { String DRIVER="oracle.jdbc.driver.OracleDriver"; String CON_STRING="jdbc:oracle:thin:@localhost:1521:xe"; String USERNAME="store"; String PASSWORD="store"; login_servlet.java ----------------- ------ import java.io.ioexception; import java.io.printwriter; import java.rmi.naming; import javax.servlet.; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.cookie; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; //This is the controller class for getting user inputs and redirecting to code for processing @WebServlet("/login_servlet")

public class login_servlet extends HttpServlet { * private static final long serialversionuid = 1L; public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html"); PrintWriter out=response.getwriter(); int status; int err=0; String username=request.getparameter("username"); String password=request.getparameter("password"); String repassword=request.getparameter("repassword"); boolean stat=verify_user.checklogin(username,password, repassword); if(stat==true ) { Cookie username = new Cookie("username", username); username.setmaxage(30*60); response.addcookie(username); rd=request.get("admin_after_login.jsp"); else { err = 1; request.setattribute("err",err); rd=request.get("create_acc_err.jsp");

register_user.java ---------- ----------- import java.sql.*; public class register_user { static int status=0; //This class creates records for new account and new cheque book request public static int register(string name, String username,string address,string password,string repassword,string email,double phone ){ Connection con=db_connection.dbconnection(); PreparedStatement ps; ps = con.preparestatement("insert into user_table values(?,?,?,?,?,?,?,?)"); int nextvalue1=db_connection.getprimarykey(); ps.setint(1,nextvalue1); 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,phone); status=ps.executeupdate(); catch (SQLException e) { return status;

registration_servlet.java ------------ ---------------- import java.io.*; import java.io.printwriter; import java.rmi.naming; import java.sql.connection; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.sqlexception; import javax.servlet.; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.cookie; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession; * Servlet implementation class error_handle @WebServlet("/registration_servlet") public class registration_servlet extends HttpServlet { private static final long serialversionuid = 1L; * @see HttpServlet#HttpServlet() * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) protected void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getwriter().append("served at: ").append(request.getcontextpath());

// response.setcontenttype("text/html"); PrintWriter out=response.getwriter(); int register_status; boolean verify_status; int update_status=0; // int ano = request.getparameter("no"); int no =0; String ano=request.getparameter("no"); if(ano!= null){ no=integer.parseint(ano); int err=0; double amount = 0; double phone = 0; String username=request.getparameter("username"); String password=request.getparameter("password"); String repassword=request.getparameter("repassword"); String email=request.getparameter("email"); String address=request.getparameter("address"); String ph=request.getparameter("phone"); if(ph!= null){ phone=double.parsedouble(ph); String username1=null; String name =request.getparameter("name"); Connection con=db_connection.dbconnection(); //if (no >0) { PreparedStatement ps=con.preparestatement("select username from user_table where no = '"+no+"'"); ResultSet rs=ps.executequery(); while(rs.next()){ username1=rs.getstring(1); // catch (SQLException e) {

//verify_status=verify_user.checklogin(username,password,repassword, usertype); register_status=register_user.register(name, username, address, password, repassword, email, phone); //update_status=update_user.update(no,name, username, address, password, repassword, email, phone, usertype); if (username1 == username ) {out.print("sorry, this username has been already been taken. Please use another username."); rd=request.get("create_acc_customer_req.jsp"); else if( register_status>0 ){ Cookie username = new Cookie("username", username); username.setmaxage(30*60); response.addcookie(username); rd=request.get("create_acc_admin_res.jsp"); later"); else{ //out.print("sorry,registration failed. please try err = 2; request.setattribute("err",err); rd=request.get("create_acc_err.jsp");

* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) verify_user.java ---------- ----------- import java.sql.*; public class verify_user { public static boolean checklogin(string username,string password, String repassword ){ boolean status=false; Connection con=db_connection.dbconnection(); PreparedStatement ps=con.preparestatement("select * from user_table where username =? and password =? and repassword =? "); ps.setstring(1,username); ps.setstring(2,password); ps.setstring(3,repassword); ResultSet rs=ps.executequery(); status=rs.next(); catch (SQLException e) { return status;