SlideShare a Scribd company logo
Servlet and JSP
Gary
07/24/2013
Question
• Blocking I/O如何處理多個read?
• I/O
– Blocking I/O
– Non-blocking I/O
– Asynchronous I/O
– Synchronous I/O
Question
• Blocking I/O model
recvfrom
application
System call
Process
datagram
Process blocks in
call to recvfrom
Wait for data
Copy data from
kernel to user
No datagram
ready
Datagram ready
Copy datagram
Copy complete
Return OK
kernel
Question
• Non-Blocking I/O model
recvfrom
application
System call
Process
datagram
Process repeatedly
calls recvfrom
waiting for an OK
return(polling)
Wait for data
Copy data from
kernel to user
No datagram
ready
Datagram ready
Copy datagram
Copy complete
Return OK
kernel
EWOULDBLOCK
recvfrom
System call No datagram
readyEWOULDBLOCK
Question
• Asynchronous I/O model
recvfrom
application
System call
Signal handler
process
datagram
Process continues
executing
Wait for data
Copy data from
kernel to user
No datagram
ready
Datagram ready
Copy datagram
Copy complete
Deliver signal
specofied in recvfrom
kernel
return
Question
• Synchronous I/O
• Definition
– A synchronous I/O operation causes the
requesting process to be blocked until that I/O
operation completes.
Question
• How to solve multiple I/O devices?
• Use select()
A
B
A
Select()
device
Question
• 手動讓process休眠
DEFINE_WAIT(my_wqentry);
初始化一個待命佇列項目
void prepare_to_wait(wait_queue_head_t *queue, wait_queue_t *my_wqentry, int state);
將待命佇列項目加進佇列
prepare_to_wait();
可以開始休眠
schedule();
重新加入排程
void finish_wait(wait_queue_head_t *queue, wait_queue_t *my_wqentry);
把柱列項目清除
Question
• Asynchronous Notification
– 當新資料進來時獲得通知
– 執行優先度低,無法使用輪詢
fcntl(STDIN_FILENO, F_SETOWN, getpid());
讓核心知道通知對象是誰
fcntl(STDIN_FILENO, FSETFL, oflags | FASYNC);
啟動臨時通知
Question
• 同時存取database
– Locking
– Timestamp
– Multiversion concurrency control
Outline
• Introduction
• CGI
• Servlet
• Implement of Servlet
• JSP
• Conclusion
Introduction
• You can use JSP or servlet to solve dynamic
web page needs. JSP is web page design
oriented, and servlet is program designed
oriented. Knowing their character can
cooperate two expertise and make the
achievement better.
CGI
• Common Gateway Interface
• A standard method for web server software to
delegate the generation of web content to
executable files.
• Web server send request to external program,
and the program response with static file.
CGI
Web Server
CGI Program Database
Web Browser
1. Request
2. Input data
3. May access database
4. Response as HTML doc
Figure: CGI workflow
CGI
• CGI can designed as any computer language.
Perl is the most popular.
• When server receive a request, it produce a
new process to execute CGI program.
• Consume many memory.
• Each CGI program is isolated.
Servlet
• In order to solve the disadvantage of CGI,
servlet is developed.
• Servlet is designed to substitute CGI.
• The word servlet is composed of “server” and
“let”. In Java, “let” means small application.
• Servlet is run in server side, and applet is run
in client side.
Servlet
Client Browser Web Server
Servlet Container
Servlet
1. Browser
requests page
2. Web server
delegates to container
3. Container executes servlet,
creating instance if required
4. Servlet executes,
generates response
5. Server
returns response
Figure: Servlet workflow
Servlet
• Web container
– Execute JSP and servlet.
– Like Java only recognizes JVM, servlet/JSP only
recognizes web container.
– Parsing HTTP request, create instance like
HttpServletRequest、 HttpServletResponse、
HttpSession
Servlet
• Servlet life cycle
– void init()
• When servlet is first loaded, initialize servlet status
– void service()
• Serve a request. Can be called multiple times.
– void destroy()
• Dispose servlet.
Servlet
• Since the output of servlet is HTML, the usage
of servlets doesn’t constrain by browser.
• No matter how many requests, only one
servlet will be loaded into JVM.
• When there is a request, there is a thread, not
process.
• Servlets is persistent until be deystroyed.
Implement of Servlet
• Environment – oracle java jdk 1.7.0
• Add path to environment variables
– JAVA_HOME
– PATH
– CLASSPATH
Implement of Servlet
• Download Apache-Tomcat-7.0.42
• Use tomcat as web server and web container
Implement of Servlet
Implement of Servlet
• javax.servlet
– The javax.servlet package contains a number of
classes and interfaces that describe and define the
contracts between a servlet class and the runtime
environment provided for an instance of such a
class by a conforming servlet container
Implement of Servlet
• javax.servlet.http
– The javax.servlet.http package contains a number
of classes and interfaces that describe and define
the contracts between a servlet class running
under the HTTP protocol and the runtime
environment provided for an instance of such a
class by a conforming servlet container.
Implement of Servlet
• javax.servlet
Implement of Servlet
• javax.servlet.http
Implement of Servlet
• service() can handle doGet() and doPost()
• Get
– The request parameter shows on URL
– Not proper for password
– Not too long data
– Good for setting as tags or bookmarks
– Don’t change the status of server
Implement of Servlet
• Post
– The request parameter is in Body
– Good for password
– Good for long data
– Not proper for tags or bookmarks
– May change content of database
Implement of Servlet
• HttpServletRequest
– The object of client sending request to server
– E.g. Form input data
• HttpServletResponse
– The object of server responding to client
– E.g. Show HTML doc on browser
Implement of Servlet
• HttpServletResponseObjectName.setContentType(“ContentType”)
• E.g. res.serContentTyoe(“text/html;charset=Big5”)
Implement of Servlet
• In order to show information on web page,
use HttpServletResponse object create a
PrintWriter object.
• And use PrintWriter to write HTML tags.
Implement of Servlet
• Write web.xml
• /WEB-INF/
/classes/
| |HelloServlet.class
|web.xml
Implement of Servlet
• Web.xml
– Used to configure welcome page、 servlet 、
filter
– Run before load servlet
url-pattern
servlet-name
servlet-class
Implement of Servlet
• The result
JSP
• HelloWorld.java
JSP
• HelloWorld.jsp
• A JSP page is basically a web page with
traditional HTML and bits of Java code.
JSP
Figure: JSP workflow
JSP
• When a JSP file is accessed, the container
converts it into a Java class that implements
the javax.servlet.jsp.HttpJspPage interface.
The various JSP building blocks are translated
into Java code and compiled into a Servlet.
JSP
• The element of JSP can be divided into three
kinds
– Directive
• Definite the static information of web page.
– Action
• Send data according to the request of client.
– Scripting
• Small piece of java code. Only execute if client request.
JSP
directive
action
scripting
JSP
• Implicit object
• Corresponds to an object in servlet
• out
– corresponds to JspWriter, which associates
PrintWriter
• Request
– corresponds to HttpServletRequest
• Response
– corresponds to HttpServletResponse
JSP
Conclusion
• Deal with JSP is easier than with servlet.
• Knowing how to write JSP code is helpful in
developing server-side web design.
Ad

More Related Content

What's hot (20)

Javax.servlet,http packages
Javax.servlet,http packagesJavax.servlet,http packages
Javax.servlet,http packages
vamsi krishna
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
Tanmoy Barman
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jsp
Ankit Minocha
 
Servlets
ServletsServlets
Servlets
Rajkiran Mummadi
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
BG Java EE Course
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
Nitin Pai
 
Servlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servletsServlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servlets
JavaEE Trainers
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
KushagraChadha1
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
Manjunatha RK
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
Dhruvin Nakrani
 
Java - Servlet - Mazenet Solution
Java - Servlet - Mazenet SolutionJava - Servlet - Mazenet Solution
Java - Servlet - Mazenet Solution
Mazenetsolution
 
Servlets
ServletsServlets
Servlets
Akshay Ballarpure
 
JDBC in Servlets
JDBC in ServletsJDBC in Servlets
JDBC in Servlets
Eleonora Ciceri
 
Servlets
ServletsServlets
Servlets
Ravi Kant Sahu
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
BG Java EE Course
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course
JavaEE Trainers
 
Jsp (java server page)
Jsp (java server page)Jsp (java server page)
Jsp (java server page)
Chitrank Dixit
 
Servlets
ServletsServlets
Servlets
ramesh kumar
 
Jsp servlets
Jsp servletsJsp servlets
Jsp servlets
Rajavel Dhandabani
 
Servlets
ServletsServlets
Servlets
Geethu Mohan
 

Similar to Servlet and JSP (20)

Servlets
ServletsServlets
Servlets
Sasidhar Kothuru
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
deepak kumar
 
servlets sessions and cookies, jdbc connectivity
servlets sessions and cookies, jdbc connectivityservlets sessions and cookies, jdbc connectivity
servlets sessions and cookies, jdbc connectivity
snehalatha790700
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Tushar B Kute
 
Module 4.pptModule 4.pptModule 4.pptModule 4.ppt
Module 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.ppt
Module 4.pptModule 4.pptModule 4.pptModule 4.ppt
tahirnaquash2
 
Servlet123jkhuiyhkjkljioyudfrtsdrestfhgb
Servlet123jkhuiyhkjkljioyudfrtsdrestfhgbServlet123jkhuiyhkjkljioyudfrtsdrestfhgb
Servlet123jkhuiyhkjkljioyudfrtsdrestfhgb
shubhangimalas1
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
MouDhara1
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
kstalin2
 
Servlet1.ppt
Servlet1.pptServlet1.ppt
Servlet1.ppt
KhushalChoudhary14
 
Servlet (1) also contains code to create it.ppt
Servlet (1) also contains code to create it.pptServlet (1) also contains code to create it.ppt
Servlet (1) also contains code to create it.ppt
juhishrivastava25
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsitricks
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsi krishna
 
SERVLETS (2).pptxintroduction to servlet with all servlets
SERVLETS (2).pptxintroduction to servlet with all servletsSERVLETS (2).pptxintroduction to servlet with all servlets
SERVLETS (2).pptxintroduction to servlet with all servlets
RadhikaP41
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsitricks
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
UNIT - 5.pptx Servlets And Database Connectivity
UNIT - 5.pptx  Servlets And Database ConnectivityUNIT - 5.pptx  Servlets And Database Connectivity
UNIT - 5.pptx Servlets And Database Connectivity
bmit1
 
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
sindhu991994
 
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database ConnectivityIT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
pkaviya
 
19servlets
19servlets19servlets
19servlets
Adil Jafri
 
servlets sessions and cookies, jdbc connectivity
servlets sessions and cookies, jdbc connectivityservlets sessions and cookies, jdbc connectivity
servlets sessions and cookies, jdbc connectivity
snehalatha790700
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Tushar B Kute
 
Module 4.pptModule 4.pptModule 4.pptModule 4.ppt
Module 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.ppt
Module 4.pptModule 4.pptModule 4.pptModule 4.ppt
tahirnaquash2
 
Servlet123jkhuiyhkjkljioyudfrtsdrestfhgb
Servlet123jkhuiyhkjkljioyudfrtsdrestfhgbServlet123jkhuiyhkjkljioyudfrtsdrestfhgb
Servlet123jkhuiyhkjkljioyudfrtsdrestfhgb
shubhangimalas1
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
kstalin2
 
Servlet (1) also contains code to create it.ppt
Servlet (1) also contains code to create it.pptServlet (1) also contains code to create it.ppt
Servlet (1) also contains code to create it.ppt
juhishrivastava25
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsitricks
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsi krishna
 
SERVLETS (2).pptxintroduction to servlet with all servlets
SERVLETS (2).pptxintroduction to servlet with all servletsSERVLETS (2).pptxintroduction to servlet with all servlets
SERVLETS (2).pptxintroduction to servlet with all servlets
RadhikaP41
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsitricks
 
UNIT - 5.pptx Servlets And Database Connectivity
UNIT - 5.pptx  Servlets And Database ConnectivityUNIT - 5.pptx  Servlets And Database Connectivity
UNIT - 5.pptx Servlets And Database Connectivity
bmit1
 
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
sindhu991994
 
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database ConnectivityIT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
pkaviya
 
Ad

More from Gary Yeh (10)

Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGL
Gary Yeh
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
Gary Yeh
 
Run-time of Node.js : V8 JavaScript Engine
Run-time of Node.js: V8 JavaScript EngineRun-time of Node.js: V8 JavaScript Engine
Run-time of Node.js : V8 JavaScript Engine
Gary Yeh
 
Linux Char Device Driver
Linux Char Device DriverLinux Char Device Driver
Linux Char Device Driver
Gary Yeh
 
JQuery UI
JQuery UIJQuery UI
JQuery UI
Gary Yeh
 
jQuery Mobile and JavaScript
jQuery Mobile and JavaScriptjQuery Mobile and JavaScript
jQuery Mobile and JavaScript
Gary Yeh
 
JQuery mobile
JQuery mobileJQuery mobile
JQuery mobile
Gary Yeh
 
Database and Java Database Connectivity
Database and Java Database ConnectivityDatabase and Java Database Connectivity
Database and Java Database Connectivity
Gary Yeh
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
Gary Yeh
 
Git Workflow
Git WorkflowGit Workflow
Git Workflow
Gary Yeh
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGL
Gary Yeh
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
Gary Yeh
 
Run-time of Node.js : V8 JavaScript Engine
Run-time of Node.js: V8 JavaScript EngineRun-time of Node.js: V8 JavaScript Engine
Run-time of Node.js : V8 JavaScript Engine
Gary Yeh
 
Linux Char Device Driver
Linux Char Device DriverLinux Char Device Driver
Linux Char Device Driver
Gary Yeh
 
jQuery Mobile and JavaScript
jQuery Mobile and JavaScriptjQuery Mobile and JavaScript
jQuery Mobile and JavaScript
Gary Yeh
 
JQuery mobile
JQuery mobileJQuery mobile
JQuery mobile
Gary Yeh
 
Database and Java Database Connectivity
Database and Java Database ConnectivityDatabase and Java Database Connectivity
Database and Java Database Connectivity
Gary Yeh
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
Gary Yeh
 
Git Workflow
Git WorkflowGit Workflow
Git Workflow
Gary Yeh
 
Ad

Recently uploaded (20)

TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 

Servlet and JSP

  • 2. Question • Blocking I/O如何處理多個read? • I/O – Blocking I/O – Non-blocking I/O – Asynchronous I/O – Synchronous I/O
  • 3. Question • Blocking I/O model recvfrom application System call Process datagram Process blocks in call to recvfrom Wait for data Copy data from kernel to user No datagram ready Datagram ready Copy datagram Copy complete Return OK kernel
  • 4. Question • Non-Blocking I/O model recvfrom application System call Process datagram Process repeatedly calls recvfrom waiting for an OK return(polling) Wait for data Copy data from kernel to user No datagram ready Datagram ready Copy datagram Copy complete Return OK kernel EWOULDBLOCK recvfrom System call No datagram readyEWOULDBLOCK
  • 5. Question • Asynchronous I/O model recvfrom application System call Signal handler process datagram Process continues executing Wait for data Copy data from kernel to user No datagram ready Datagram ready Copy datagram Copy complete Deliver signal specofied in recvfrom kernel return
  • 6. Question • Synchronous I/O • Definition – A synchronous I/O operation causes the requesting process to be blocked until that I/O operation completes.
  • 7. Question • How to solve multiple I/O devices? • Use select() A B A Select() device
  • 8. Question • 手動讓process休眠 DEFINE_WAIT(my_wqentry); 初始化一個待命佇列項目 void prepare_to_wait(wait_queue_head_t *queue, wait_queue_t *my_wqentry, int state); 將待命佇列項目加進佇列 prepare_to_wait(); 可以開始休眠 schedule(); 重新加入排程 void finish_wait(wait_queue_head_t *queue, wait_queue_t *my_wqentry); 把柱列項目清除
  • 9. Question • Asynchronous Notification – 當新資料進來時獲得通知 – 執行優先度低,無法使用輪詢 fcntl(STDIN_FILENO, F_SETOWN, getpid()); 讓核心知道通知對象是誰 fcntl(STDIN_FILENO, FSETFL, oflags | FASYNC); 啟動臨時通知
  • 10. Question • 同時存取database – Locking – Timestamp – Multiversion concurrency control
  • 11. Outline • Introduction • CGI • Servlet • Implement of Servlet • JSP • Conclusion
  • 12. Introduction • You can use JSP or servlet to solve dynamic web page needs. JSP is web page design oriented, and servlet is program designed oriented. Knowing their character can cooperate two expertise and make the achievement better.
  • 13. CGI • Common Gateway Interface • A standard method for web server software to delegate the generation of web content to executable files. • Web server send request to external program, and the program response with static file.
  • 14. CGI Web Server CGI Program Database Web Browser 1. Request 2. Input data 3. May access database 4. Response as HTML doc Figure: CGI workflow
  • 15. CGI • CGI can designed as any computer language. Perl is the most popular. • When server receive a request, it produce a new process to execute CGI program. • Consume many memory. • Each CGI program is isolated.
  • 16. Servlet • In order to solve the disadvantage of CGI, servlet is developed. • Servlet is designed to substitute CGI. • The word servlet is composed of “server” and “let”. In Java, “let” means small application. • Servlet is run in server side, and applet is run in client side.
  • 17. Servlet Client Browser Web Server Servlet Container Servlet 1. Browser requests page 2. Web server delegates to container 3. Container executes servlet, creating instance if required 4. Servlet executes, generates response 5. Server returns response Figure: Servlet workflow
  • 18. Servlet • Web container – Execute JSP and servlet. – Like Java only recognizes JVM, servlet/JSP only recognizes web container. – Parsing HTTP request, create instance like HttpServletRequest、 HttpServletResponse、 HttpSession
  • 19. Servlet • Servlet life cycle – void init() • When servlet is first loaded, initialize servlet status – void service() • Serve a request. Can be called multiple times. – void destroy() • Dispose servlet.
  • 20. Servlet • Since the output of servlet is HTML, the usage of servlets doesn’t constrain by browser. • No matter how many requests, only one servlet will be loaded into JVM. • When there is a request, there is a thread, not process. • Servlets is persistent until be deystroyed.
  • 21. Implement of Servlet • Environment – oracle java jdk 1.7.0 • Add path to environment variables – JAVA_HOME – PATH – CLASSPATH
  • 22. Implement of Servlet • Download Apache-Tomcat-7.0.42 • Use tomcat as web server and web container
  • 24. Implement of Servlet • javax.servlet – The javax.servlet package contains a number of classes and interfaces that describe and define the contracts between a servlet class and the runtime environment provided for an instance of such a class by a conforming servlet container
  • 25. Implement of Servlet • javax.servlet.http – The javax.servlet.http package contains a number of classes and interfaces that describe and define the contracts between a servlet class running under the HTTP protocol and the runtime environment provided for an instance of such a class by a conforming servlet container.
  • 26. Implement of Servlet • javax.servlet
  • 27. Implement of Servlet • javax.servlet.http
  • 28. Implement of Servlet • service() can handle doGet() and doPost() • Get – The request parameter shows on URL – Not proper for password – Not too long data – Good for setting as tags or bookmarks – Don’t change the status of server
  • 29. Implement of Servlet • Post – The request parameter is in Body – Good for password – Good for long data – Not proper for tags or bookmarks – May change content of database
  • 30. Implement of Servlet • HttpServletRequest – The object of client sending request to server – E.g. Form input data • HttpServletResponse – The object of server responding to client – E.g. Show HTML doc on browser
  • 31. Implement of Servlet • HttpServletResponseObjectName.setContentType(“ContentType”) • E.g. res.serContentTyoe(“text/html;charset=Big5”)
  • 32. Implement of Servlet • In order to show information on web page, use HttpServletResponse object create a PrintWriter object. • And use PrintWriter to write HTML tags.
  • 33. Implement of Servlet • Write web.xml • /WEB-INF/ /classes/ | |HelloServlet.class |web.xml
  • 34. Implement of Servlet • Web.xml – Used to configure welcome page、 servlet 、 filter – Run before load servlet url-pattern servlet-name servlet-class
  • 37. JSP • HelloWorld.jsp • A JSP page is basically a web page with traditional HTML and bits of Java code.
  • 39. JSP • When a JSP file is accessed, the container converts it into a Java class that implements the javax.servlet.jsp.HttpJspPage interface. The various JSP building blocks are translated into Java code and compiled into a Servlet.
  • 40. JSP • The element of JSP can be divided into three kinds – Directive • Definite the static information of web page. – Action • Send data according to the request of client. – Scripting • Small piece of java code. Only execute if client request.
  • 42. JSP • Implicit object • Corresponds to an object in servlet • out – corresponds to JspWriter, which associates PrintWriter • Request – corresponds to HttpServletRequest • Response – corresponds to HttpServletResponse
  • 43. JSP
  • 44. Conclusion • Deal with JSP is easier than with servlet. • Knowing how to write JSP code is helpful in developing server-side web design.