SlideShare a Scribd company logo
1 of 9
04/06/2013 - 05/06/2013
BKBIET Phase I
Day 2 , Day 3
Thursday, 13 June 13
Today....
✤ Technical
✤ Servlet Platform
✤ tomcat
✤ Database
✤ postgreSQL,mysql,h2
✤ Atlassian - Jira
Thursday, 13 June 13
Servlets
✤ Servlets - Java CGI?
✤ run inside a servlet container
✤ encapsulate HTTP in java objects
✤ HTTPServletRequest
✤ HTTPServletResponse
✤ provide methods to process HTTP methods
✤ doGet
✤ doPost
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Hello World!</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World!</h1>");
out.println("</body>");
out.println("</html>");
}
}
Thursday, 13 June 13
Exercise!
✤ Create a Hello World Servlet!
✤ create a project in eclipse
✤ create src file
✤ create web.xml file
✤ add source/details
✤ deploy!
✤ Development Stations!!
Thursday, 13 June 13
Databases
✤ Relational Databases
✤ ACID
✤ Transactions
✤ JDBC
✤ Database Connections
✤ Queries
✤ ResultSets!
Thursday, 13 June 13
Exercise
✤ Create a db bkbiet
✤ Create a table bkbiet
✤ id
✤ name
✤ age
✤ email
✤ Use java to connect to db
✤ insert your own data in table
CREATE TABLE `bkbiet`.`bkbiet` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(45) NOT NULL ,
`stream` VARCHAR(45) NOT NULL ,
`email` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`id`) ,
UNIQUE INDEX `id_UNIQUE` (`id` ASC) );
String insertTableSQL = "INSERT INTO DBUSER"
! ! + "(USER_ID, USERNAME, CREATED_BY, CREATED_DATE) VALUES"
! ! + "(?,?,?,?)";
PreparedStatement preparedStatement =
dbConnection.prepareStatement(insertTableSQL);
preparedStatement.setInt(1, 11);
preparedStatement.setString(2, "mkyong");
preparedStatement.setString(3, "system");
preparedStatement.setTimestamp(4, getCurrentTimeStamp());
// execute insert SQL stetement
preparedStatement .executeUpdate();
Thursday, 13 June 13
Templates
✤ Difficult to write long html pages
✤ requires templates
✤ Enter JSP
✤ Servlets feed data(model) to jsp
✤ converts to html pages
✤ JSP get converted to servlets at runtime
Thursday, 13 June 13
MVC Recall
✤ Model-View-Controller
✤ separate the data from the view
✤ Servlet: Controller
✤ DAO: Data Access Object
✤ View: JSP
Thursday, 13 June 13
Exercise
✤ Create a web site for users
✤ enter their details into the db
✤ create a page to view all details
✤ search for a user
<HTML>
<HEAD>
<TITLE>A Sample Form Using GET</TITLE>
</HEAD>
<BODY>
<FORM ACTION="http://localhost:8080/bkbiet/
BKBIETServlet" METHOD=”POST”>
<CENTER>
Name:
<INPUT TYPE="TEXT" NAME="name"
VALUE="Joe"><BR>
Last name:
<INPUT TYPE="TEXT" NAME="age" VALUE="26"><BR>
<INPUT TYPE="email" NAME="email"
VALUE="abc@example.com"><P>
<INPUT TYPE="SUBMIT">
<!-- Press this button to submit form -->
</CENTER>
</FORM>
</BODY>
</HTML>
Thursday, 13 June 13

More Related Content

What's hot

5 kinesis lightning
5 kinesis lightning5 kinesis lightning
5 kinesis lightning
BigDataCamp
 
Adventures in Multithreaded Core Data
Adventures in Multithreaded Core DataAdventures in Multithreaded Core Data
Adventures in Multithreaded Core Data
Inferis
 
Distributed in memory data grid
Distributed in memory data gridDistributed in memory data grid
Distributed in memory data grid
Alexander Albul
 

What's hot (18)

利用Init connect做mysql clients stat 用户审计
 利用Init connect做mysql clients stat 用户审计 利用Init connect做mysql clients stat 用户审计
利用Init connect做mysql clients stat 用户审计
 
ReactJS & Material-ui Hello world
ReactJS & Material-ui Hello worldReactJS & Material-ui Hello world
ReactJS & Material-ui Hello world
 
Getting Started With #Drools 6 Slides - JBUG Denmark
Getting Started With #Drools 6 Slides - JBUG DenmarkGetting Started With #Drools 6 Slides - JBUG Denmark
Getting Started With #Drools 6 Slides - JBUG Denmark
 
Real World Mocking In Swift
Real World Mocking In SwiftReal World Mocking In Swift
Real World Mocking In Swift
 
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Morocco 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Morocco 201910 Excellent Ways to Secure Your Spring Boot Application - Devoxx Morocco 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Morocco 2019
 
5 kinesis lightning
5 kinesis lightning5 kinesis lightning
5 kinesis lightning
 
Design & Performance - Steve Souders at Fastly Altitude 2015
Design & Performance - Steve Souders at Fastly Altitude 2015Design & Performance - Steve Souders at Fastly Altitude 2015
Design & Performance - Steve Souders at Fastly Altitude 2015
 
Adventures in Multithreaded Core Data
Adventures in Multithreaded Core DataAdventures in Multithreaded Core Data
Adventures in Multithreaded Core Data
 
Cookies
CookiesCookies
Cookies
 
Week6
Week6Week6
Week6
 
Fluent plugin-dstat
Fluent plugin-dstatFluent plugin-dstat
Fluent plugin-dstat
 
Multi-threaded CoreData Done Right
Multi-threaded CoreData Done RightMulti-threaded CoreData Done Right
Multi-threaded CoreData Done Right
 
Distributed in memory data grid
Distributed in memory data gridDistributed in memory data grid
Distributed in memory data grid
 
Potential gotchas in making a backbone app
Potential gotchas in making a backbone appPotential gotchas in making a backbone app
Potential gotchas in making a backbone app
 
Quick MySQL performance check
Quick MySQL performance checkQuick MySQL performance check
Quick MySQL performance check
 
node.js Module Development
node.js Module Developmentnode.js Module Development
node.js Module Development
 
Pragmatic Introduction to React — Maayan Glikser
Pragmatic Introduction to React — Maayan GlikserPragmatic Introduction to React — Maayan Glikser
Pragmatic Introduction to React — Maayan Glikser
 
Reactive Quarkus – A Java Mutiny! | DevNation Tech Talk
Reactive Quarkus – A Java Mutiny! | DevNation Tech TalkReactive Quarkus – A Java Mutiny! | DevNation Tech Talk
Reactive Quarkus – A Java Mutiny! | DevNation Tech Talk
 

Similar to Bkbiet day2 & 3

Get Back in Control of Your SQL with jOOQ at #Java2Days
Get Back in Control of Your SQL with jOOQ at #Java2DaysGet Back in Control of Your SQL with jOOQ at #Java2Days
Get Back in Control of Your SQL with jOOQ at #Java2Days
Lukas Eder
 
The vJUG talk about jOOQ: Get Back in Control of Your SQL
The vJUG talk about jOOQ: Get Back in Control of Your SQLThe vJUG talk about jOOQ: Get Back in Control of Your SQL
The vJUG talk about jOOQ: Get Back in Control of Your SQL
Lukas Eder
 
Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8
PrinceGuru MS
 
05 status-codes
05 status-codes05 status-codes
05 status-codes
snopteck
 
02 up close with servlets
02 up close with servlets02 up close with servlets
02 up close with servlets
dhrubo kayal
 

Similar to Bkbiet day2 & 3 (20)

servlets
servletsservlets
servlets
 
Going Offline with Gears And GWT
Going Offline with Gears And GWTGoing Offline with Gears And GWT
Going Offline with Gears And GWT
 
Advance java
Advance javaAdvance java
Advance java
 
Get Back in Control of your SQL
Get Back in Control of your SQLGet Back in Control of your SQL
Get Back in Control of your SQL
 
Get Back in Control of Your SQL with jOOQ at #Java2Days
Get Back in Control of Your SQL with jOOQ at #Java2DaysGet Back in Control of Your SQL with jOOQ at #Java2Days
Get Back in Control of Your SQL with jOOQ at #Java2Days
 
The vJUG talk about jOOQ: Get Back in Control of Your SQL
The vJUG talk about jOOQ: Get Back in Control of Your SQLThe vJUG talk about jOOQ: Get Back in Control of Your SQL
The vJUG talk about jOOQ: Get Back in Control of Your SQL
 
Sqladria 2009 SRC
Sqladria 2009 SRCSqladria 2009 SRC
Sqladria 2009 SRC
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Java and xml
Java and xmlJava and xml
Java and xml
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web development
 
Core Php Component Presentation
Core Php Component PresentationCore Php Component Presentation
Core Php Component Presentation
 
Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1
 
Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long
 
Presentation
PresentationPresentation
Presentation
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
05 status-codes
05 status-codes05 status-codes
05 status-codes
 
Requery overview
Requery overviewRequery overview
Requery overview
 
02 up close with servlets
02 up close with servlets02 up close with servlets
02 up close with servlets
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

Bkbiet day2 & 3

  • 1. 04/06/2013 - 05/06/2013 BKBIET Phase I Day 2 , Day 3 Thursday, 13 June 13
  • 2. Today.... ✤ Technical ✤ Servlet Platform ✤ tomcat ✤ Database ✤ postgreSQL,mysql,h2 ✤ Atlassian - Jira Thursday, 13 June 13
  • 3. Servlets ✤ Servlets - Java CGI? ✤ run inside a servlet container ✤ encapsulate HTTP in java objects ✤ HTTPServletRequest ✤ HTTPServletResponse ✤ provide methods to process HTTP methods ✤ doGet ✤ doPost public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<head>"); out.println("<title>Hello World!</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>Hello World!</h1>"); out.println("</body>"); out.println("</html>"); } } Thursday, 13 June 13
  • 4. Exercise! ✤ Create a Hello World Servlet! ✤ create a project in eclipse ✤ create src file ✤ create web.xml file ✤ add source/details ✤ deploy! ✤ Development Stations!! Thursday, 13 June 13
  • 5. Databases ✤ Relational Databases ✤ ACID ✤ Transactions ✤ JDBC ✤ Database Connections ✤ Queries ✤ ResultSets! Thursday, 13 June 13
  • 6. Exercise ✤ Create a db bkbiet ✤ Create a table bkbiet ✤ id ✤ name ✤ age ✤ email ✤ Use java to connect to db ✤ insert your own data in table CREATE TABLE `bkbiet`.`bkbiet` ( `id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR(45) NOT NULL , `stream` VARCHAR(45) NOT NULL , `email` VARCHAR(45) NOT NULL , PRIMARY KEY (`id`) , UNIQUE INDEX `id_UNIQUE` (`id` ASC) ); String insertTableSQL = "INSERT INTO DBUSER" ! ! + "(USER_ID, USERNAME, CREATED_BY, CREATED_DATE) VALUES" ! ! + "(?,?,?,?)"; PreparedStatement preparedStatement = dbConnection.prepareStatement(insertTableSQL); preparedStatement.setInt(1, 11); preparedStatement.setString(2, "mkyong"); preparedStatement.setString(3, "system"); preparedStatement.setTimestamp(4, getCurrentTimeStamp()); // execute insert SQL stetement preparedStatement .executeUpdate(); Thursday, 13 June 13
  • 7. Templates ✤ Difficult to write long html pages ✤ requires templates ✤ Enter JSP ✤ Servlets feed data(model) to jsp ✤ converts to html pages ✤ JSP get converted to servlets at runtime Thursday, 13 June 13
  • 8. MVC Recall ✤ Model-View-Controller ✤ separate the data from the view ✤ Servlet: Controller ✤ DAO: Data Access Object ✤ View: JSP Thursday, 13 June 13
  • 9. Exercise ✤ Create a web site for users ✤ enter their details into the db ✤ create a page to view all details ✤ search for a user <HTML> <HEAD> <TITLE>A Sample Form Using GET</TITLE> </HEAD> <BODY> <FORM ACTION="http://localhost:8080/bkbiet/ BKBIETServlet" METHOD=”POST”> <CENTER> Name: <INPUT TYPE="TEXT" NAME="name" VALUE="Joe"><BR> Last name: <INPUT TYPE="TEXT" NAME="age" VALUE="26"><BR> <INPUT TYPE="email" NAME="email" VALUE="abc@example.com"><P> <INPUT TYPE="SUBMIT"> <!-- Press this button to submit form --> </CENTER> </FORM> </BODY> </HTML> Thursday, 13 June 13