SlideShare una empresa de Scribd logo
1 de 32
Web Technologies
4th Lecture: JSP and such

Σάββατο, 2 Νοεμβρίου 2013
Last Week
• HTML & CSS
• TCP/IP, DNS, URL, URI
• HTTP and such
URL (and many other UR*s)
• Uniform Resource Locators
Ports
• A 16-bit number that
identifies a particular
program on the server
hardware.
• 0-1023 reserved
• sys-admins control them
The apache
file system
Missed
last
week
Missed last week
Static vs Dynamic content
Static vs. dynamic content
Dynamic (deep) Web
• Dynamic pages don’t exist before the request
comes in.
• It’s like making an HTML page out of air.
– request comes in,
– helper app “writes” the HTML, and
– web server gets it back to the client.
Common Gateway Interface (CGI)
• a standard method for web servers software
to delegate the generation of web pages to
executable files.
• Such files are known as CGI scripts
– they are programs,
• often stand-alone applications,
• usually written in a scripting language.
example
CGI (nonJava)
approach
Perl, C, Python, PHP, …
What’s wrong with CGI?
• Logical
– Java is suppose to be the language of the internet

• Performance
– Light-weight
– Easy thread manipulation

• Productivity
– J2EE
Servlet: prepare
• Build a directory tree

• Write the two files
Servlet: Write
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Ch1Servlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException {

Save it to
Servlet.java

PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();
out.println(“<html> “ +
“<body>” +
“<h1 align=center>HF’s Chapter1 Servlet</h1>” +
“<br>” + today + “</body>” + “</html>”);
}
}
Servlet: deploy (1)
<?xml version=”1.0” encoding=”ISO-8851-1” ?>
<web-app xmlns=”http://java.sun.com/xml/ns/j2ee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”
version=”2.4”>
<servlet>
<servlet-name>Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
Save this
</servlet>
<servlet-mapping>
<servlet-name>Servlet</servlet-name>
<url-pattern>/Serv1</url-pattern>
</servlet-mapping>
</web-app>

deployment
descriptor
(DD) to
web.xml
Servlet: deploy (2)
Save your files in your file system
Servlet: deploy (3) and use
•
•
•
•

Compile
Transfer to Tomcat’s file system
Start Tomcat
Click path in your browser
But …
• Stuff HTML as a string into java (println)?
• Why not stuff Java into HTML (or XML)?
Web page
designer

Apps
developer

Java Server Pages JSP
What is a Container?
What a Container offers?
• Help you to concentrate on your business logic
than programming details
– Communication
– Lifecycle Management
– Multithreading Support
– Declarative Security
– JSP Support
How the Container handles requests?
Back to the code (servlet.java)
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Ch1Servlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException {

PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();
out.println(“<html> “ +
“<body>” +
“<h1 align=center>HF’s Chapter1 Servlet</h1>” +
“<br>” + today + “</body>” + “</html>”);
}
}
Questions
• Where service() comes from?
• How the container finds the correct servlet?
• Does the URL define where exactly the servlet
is?
• Possible answers
– The user gives precise URL
– The container’s tool does the mapping
– We store the mapping to the properties table
Three different names for a servlet
Why?
• Flexibility
• Security
Map URLs top Servlet with DD
Deployment
Descriptor (DD)
has 2 elements

<web-app ...>
<servlet>
<servlet-name>Internal name 1</servlet-name>
<servlet-class>foo.Servlet1</servlet-class>
</servlet>
<servlet>
<servlet-name>Internal name 2</servlet-name>
<servlet-class>foo.Servlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Internal name 1</servlet-name>
<url-pattern>/Public1</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Internal name 2</servlet-name>
<url-pattern>/Public2</url-pattern>
</servlet-mapping>
</web-app>
Manipulate without touching with DD
• Minimizes touching source code that has already
been tested.
• fine-tune your app’s capabilities, even if you
don’t have the source code.
• adapt your application to different resources (like
databases), without having to recompile and test
any code.
• maintain dynamic security info like access control
lists and security roles.
• non-programmers may modify and deploy your
web applications.
Prepare Yourself
• http://tomcat.apache.org/tomcat-7.0doc/appdev/
• Netbeans
• Stackoverflow and friends

Más contenido relacionado

La actualidad más candente

Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails applicationArrrrCamp
 
"Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets
 "Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets "Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets
"Fast / Resilient / .NET – What to Choose?" Serhiy KalinetsFwdays
 
Mtn view sql server nov 2014
Mtn view sql server nov 2014Mtn view sql server nov 2014
Mtn view sql server nov 2014EspressoLogic
 
Elasticsearch JVM-MX Meetup April 2016
Elasticsearch JVM-MX Meetup April 2016Elasticsearch JVM-MX Meetup April 2016
Elasticsearch JVM-MX Meetup April 2016Domingo Suarez Torres
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Codemotion
 
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...MongoDB
 
4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web FrameworksJoe Kutner
 
Camel oneactivemq posta-final
Camel oneactivemq posta-finalCamel oneactivemq posta-final
Camel oneactivemq posta-finalChristian Posta
 
Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Sam Muhanguzi
 
Solving Enterprise Integration with Apache Camel
Solving Enterprise Integration with Apache CamelSolving Enterprise Integration with Apache Camel
Solving Enterprise Integration with Apache CamelChristian Posta
 
How fluentd fits into the modern software landscape
How fluentd fits into the modern software landscapeHow fluentd fits into the modern software landscape
How fluentd fits into the modern software landscapePhil Wilkins
 
Store
StoreStore
StoreESUG
 
How to bake reactive behavior into your Java EE applications
How to bake reactive behavior into your Java EE applicationsHow to bake reactive behavior into your Java EE applications
How to bake reactive behavior into your Java EE applicationsOndrej Mihályi
 
How to bake reactive behavior into your Java EE applications
How to bake reactive behavior into your Java EE applicationsHow to bake reactive behavior into your Java EE applications
How to bake reactive behavior into your Java EE applicationsOndrej Mihályi
 
Indroduction to Web Application
Indroduction to Web ApplicationIndroduction to Web Application
Indroduction to Web Applicationtorny10
 
HTML5 Programming
HTML5 ProgrammingHTML5 Programming
HTML5 Programminghotrannam
 
Moving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco RepositoryMoving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco RepositoryJeff Potts
 

La actualidad más candente (20)

Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails application
 
"Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets
 "Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets "Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets
"Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets
 
Mtn view sql server nov 2014
Mtn view sql server nov 2014Mtn view sql server nov 2014
Mtn view sql server nov 2014
 
WebDev Crash Course
WebDev Crash CourseWebDev Crash Course
WebDev Crash Course
 
Elasticsearch JVM-MX Meetup April 2016
Elasticsearch JVM-MX Meetup April 2016Elasticsearch JVM-MX Meetup April 2016
Elasticsearch JVM-MX Meetup April 2016
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
Windows 8 Apps and the Outside World
Windows 8 Apps and the Outside WorldWindows 8 Apps and the Outside World
Windows 8 Apps and the Outside World
 
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
 
4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web Frameworks
 
Camel oneactivemq posta-final
Camel oneactivemq posta-finalCamel oneactivemq posta-final
Camel oneactivemq posta-final
 
Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1
 
Solving Enterprise Integration with Apache Camel
Solving Enterprise Integration with Apache CamelSolving Enterprise Integration with Apache Camel
Solving Enterprise Integration with Apache Camel
 
How fluentd fits into the modern software landscape
How fluentd fits into the modern software landscapeHow fluentd fits into the modern software landscape
How fluentd fits into the modern software landscape
 
Store
StoreStore
Store
 
zigbee
zigbeezigbee
zigbee
 
How to bake reactive behavior into your Java EE applications
How to bake reactive behavior into your Java EE applicationsHow to bake reactive behavior into your Java EE applications
How to bake reactive behavior into your Java EE applications
 
How to bake reactive behavior into your Java EE applications
How to bake reactive behavior into your Java EE applicationsHow to bake reactive behavior into your Java EE applications
How to bake reactive behavior into your Java EE applications
 
Indroduction to Web Application
Indroduction to Web ApplicationIndroduction to Web Application
Indroduction to Web Application
 
HTML5 Programming
HTML5 ProgrammingHTML5 Programming
HTML5 Programming
 
Moving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco RepositoryMoving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco Repository
 

Destacado

Θεμελιώδες Θεώρημα (μέρος 2ο)
Θεμελιώδες Θεώρημα (μέρος 2ο)Θεμελιώδες Θεώρημα (μέρος 2ο)
Θεμελιώδες Θεώρημα (μέρος 2ο)Manolis Vavalis
 
14η διάλεξη Γραμμικής Άλγεβρας
14η διάλεξη Γραμμικής Άλγεβρας14η διάλεξη Γραμμικής Άλγεβρας
14η διάλεξη Γραμμικής ΆλγεβραςManolis Vavalis
 
Μοντέλα διάχυσης καρκινικών όγκων εγκεφάλου
Μοντέλα διάχυσης καρκινικών όγκων εγκεφάλουΜοντέλα διάχυσης καρκινικών όγκων εγκεφάλου
Μοντέλα διάχυσης καρκινικών όγκων εγκεφάλουManolis Vavalis
 
17η διάλεξη Γραμμικής Άλγεβρας
17η διάλεξη Γραμμικής Άλγεβρας17η διάλεξη Γραμμικής Άλγεβρας
17η διάλεξη Γραμμικής ΆλγεβραςManolis Vavalis
 
22η διάλεξη Γραμμικής Άλγεβρας
22η διάλεξη Γραμμικής Άλγεβρας22η διάλεξη Γραμμικής Άλγεβρας
22η διάλεξη Γραμμικής ΆλγεβραςManolis Vavalis
 
23η διάλεξη Γραμμικής Άλγεβρας
23η διάλεξη Γραμμικής Άλγεβρας23η διάλεξη Γραμμικής Άλγεβρας
23η διάλεξη Γραμμικής ΆλγεβραςManolis Vavalis
 
13η διάλεξη Γραμμικής Άλγεβρας
13η διάλεξη Γραμμικής Άλγεβρας13η διάλεξη Γραμμικής Άλγεβρας
13η διάλεξη Γραμμικής ΆλγεβραςManolis Vavalis
 
7η διάλεξη Γραμμικής Άγεβρας
7η διάλεξη Γραμμικής Άγεβρας7η διάλεξη Γραμμικής Άγεβρας
7η διάλεξη Γραμμικής ΆγεβραςManolis Vavalis
 
7η και 8η διάλεξη - Διανύσματα, Πίνακες, Πράξεις, Ομογενή Συστήματα
7η και 8η διάλεξη - Διανύσματα, Πίνακες, Πράξεις, Ομογενή Συστήματα7η και 8η διάλεξη - Διανύσματα, Πίνακες, Πράξεις, Ομογενή Συστήματα
7η και 8η διάλεξη - Διανύσματα, Πίνακες, Πράξεις, Ομογενή ΣυστήματαManolis Vavalis
 
Ch. 13 filters and wrappers
Ch. 13 filters and wrappersCh. 13 filters and wrappers
Ch. 13 filters and wrappersManolis Vavalis
 
Ορθοκανονικοποίηση - Ανάλυση GR
Ορθοκανονικοποίηση - Ανάλυση GRΟρθοκανονικοποίηση - Ανάλυση GR
Ορθοκανονικοποίηση - Ανάλυση GRManolis Vavalis
 
presentasi teknik informatika
presentasi teknik informatika presentasi teknik informatika
presentasi teknik informatika Elsa Agustina
 
Qgk3023 program kesihatan_sekolah_tajuk
Qgk3023 program kesihatan_sekolah_tajukQgk3023 program kesihatan_sekolah_tajuk
Qgk3023 program kesihatan_sekolah_tajukPea Paradiso
 
Analisis telediario nocturno
Analisis telediario nocturnoAnalisis telediario nocturno
Analisis telediario nocturnoEric Quintanilla
 
Composicion de la atmosfera
Composicion de la atmosferaComposicion de la atmosfera
Composicion de la atmosferaGerardo Manzo
 

Destacado (20)

Θεμελιώδες Θεώρημα (μέρος 2ο)
Θεμελιώδες Θεώρημα (μέρος 2ο)Θεμελιώδες Θεώρημα (μέρος 2ο)
Θεμελιώδες Θεώρημα (μέρος 2ο)
 
14η διάλεξη Γραμμικής Άλγεβρας
14η διάλεξη Γραμμικής Άλγεβρας14η διάλεξη Γραμμικής Άλγεβρας
14η διάλεξη Γραμμικής Άλγεβρας
 
Μοντέλα διάχυσης καρκινικών όγκων εγκεφάλου
Μοντέλα διάχυσης καρκινικών όγκων εγκεφάλουΜοντέλα διάχυσης καρκινικών όγκων εγκεφάλου
Μοντέλα διάχυσης καρκινικών όγκων εγκεφάλου
 
17η διάλεξη Γραμμικής Άλγεβρας
17η διάλεξη Γραμμικής Άλγεβρας17η διάλεξη Γραμμικής Άλγεβρας
17η διάλεξη Γραμμικής Άλγεβρας
 
22η διάλεξη Γραμμικής Άλγεβρας
22η διάλεξη Γραμμικής Άλγεβρας22η διάλεξη Γραμμικής Άλγεβρας
22η διάλεξη Γραμμικής Άλγεβρας
 
23η διάλεξη Γραμμικής Άλγεβρας
23η διάλεξη Γραμμικής Άλγεβρας23η διάλεξη Γραμμικής Άλγεβρας
23η διάλεξη Γραμμικής Άλγεβρας
 
13η διάλεξη Γραμμικής Άλγεβρας
13η διάλεξη Γραμμικής Άλγεβρας13η διάλεξη Γραμμικής Άλγεβρας
13η διάλεξη Γραμμικής Άλγεβρας
 
7η διάλεξη Γραμμικής Άγεβρας
7η διάλεξη Γραμμικής Άγεβρας7η διάλεξη Γραμμικής Άγεβρας
7η διάλεξη Γραμμικής Άγεβρας
 
7η και 8η διάλεξη - Διανύσματα, Πίνακες, Πράξεις, Ομογενή Συστήματα
7η και 8η διάλεξη - Διανύσματα, Πίνακες, Πράξεις, Ομογενή Συστήματα7η και 8η διάλεξη - Διανύσματα, Πίνακες, Πράξεις, Ομογενή Συστήματα
7η και 8η διάλεξη - Διανύσματα, Πίνακες, Πράξεις, Ομογενή Συστήματα
 
Ch. 13 filters and wrappers
Ch. 13 filters and wrappersCh. 13 filters and wrappers
Ch. 13 filters and wrappers
 
Ch. 12 security
Ch. 12 securityCh. 12 security
Ch. 12 security
 
Page rank
Page rankPage rank
Page rank
 
Ορίζουσες
ΟρίζουσεςΟρίζουσες
Ορίζουσες
 
Ορθοκανονικοποίηση - Ανάλυση GR
Ορθοκανονικοποίηση - Ανάλυση GRΟρθοκανονικοποίηση - Ανάλυση GR
Ορθοκανονικοποίηση - Ανάλυση GR
 
presentasi teknik informatika
presentasi teknik informatika presentasi teknik informatika
presentasi teknik informatika
 
Igor silchenko
Igor silchenkoIgor silchenko
Igor silchenko
 
Qgk3023 program kesihatan_sekolah_tajuk
Qgk3023 program kesihatan_sekolah_tajukQgk3023 program kesihatan_sekolah_tajuk
Qgk3023 program kesihatan_sekolah_tajuk
 
Analisis telediario nocturno
Analisis telediario nocturnoAnalisis telediario nocturno
Analisis telediario nocturno
 
Composicion de la atmosfera
Composicion de la atmosferaComposicion de la atmosfera
Composicion de la atmosfera
 
Allergy1
Allergy1Allergy1
Allergy1
 

Similar a 4th Lecture: JSP and such

Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postvamsitricks
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postvamsitricks
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postvamsi krishna
 
01 - Web Programming Intro.pptx
01 - Web Programming Intro.pptx01 - Web Programming Intro.pptx
01 - Web Programming Intro.pptxKarina González
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 
Web technologies lesson 1
Web technologies   lesson 1Web technologies   lesson 1
Web technologies lesson 1nhepner
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Henry S
 
Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat ClientPaul Klipp
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationStuart (Pid) Williams
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevFelix Geisendörfer
 
Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)Gera Paulos
 
BITM3730Week12.pptx
BITM3730Week12.pptxBITM3730Week12.pptx
BITM3730Week12.pptxMattMarino13
 
web-servers3952 (1)qwjelkjqwlkjkqlwe.ppt
web-servers3952 (1)qwjelkjqwlkjkqlwe.pptweb-servers3952 (1)qwjelkjqwlkjkqlwe.ppt
web-servers3952 (1)qwjelkjqwlkjkqlwe.ppt20521742
 

Similar a 4th Lecture: JSP and such (20)

Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Real time web
Real time webReal time web
Real time web
 
01 - Web Programming Intro.pptx
01 - Web Programming Intro.pptx01 - Web Programming Intro.pptx
01 - Web Programming Intro.pptx
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Web technologies lesson 1
Web technologies   lesson 1Web technologies   lesson 1
Web technologies lesson 1
 
Node.js for beginner
Node.js for beginnerNode.js for beginner
Node.js for beginner
 
Servlets
ServletsServlets
Servlets
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
 
Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat Client
 
Lecture 7: Server side programming
Lecture 7: Server side programmingLecture 7: Server side programming
Lecture 7: Server side programming
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
Servlet by Rj
Servlet by RjServlet by Rj
Servlet by Rj
 
01 java intro
01 java intro01 java intro
01 java intro
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
 
Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)
 
BITM3730Week12.pptx
BITM3730Week12.pptxBITM3730Week12.pptx
BITM3730Week12.pptx
 
web-servers3952 (1)qwjelkjqwlkjkqlwe.ppt
web-servers3952 (1)qwjelkjqwlkjkqlwe.pptweb-servers3952 (1)qwjelkjqwlkjkqlwe.ppt
web-servers3952 (1)qwjelkjqwlkjkqlwe.ppt
 

Último

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Último (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

4th Lecture: JSP and such

  • 1. Web Technologies 4th Lecture: JSP and such Σάββατο, 2 Νοεμβρίου 2013
  • 2. Last Week • HTML & CSS • TCP/IP, DNS, URL, URI • HTTP and such
  • 3.
  • 4. URL (and many other UR*s) • Uniform Resource Locators
  • 5. Ports • A 16-bit number that identifies a particular program on the server hardware. • 0-1023 reserved • sys-admins control them
  • 11. Dynamic (deep) Web • Dynamic pages don’t exist before the request comes in. • It’s like making an HTML page out of air. – request comes in, – helper app “writes” the HTML, and – web server gets it back to the client.
  • 12. Common Gateway Interface (CGI) • a standard method for web servers software to delegate the generation of web pages to executable files. • Such files are known as CGI scripts – they are programs, • often stand-alone applications, • usually written in a scripting language.
  • 15. What’s wrong with CGI? • Logical – Java is suppose to be the language of the internet • Performance – Light-weight – Easy thread manipulation • Productivity – J2EE
  • 16. Servlet: prepare • Build a directory tree • Write the two files
  • 17. Servlet: Write import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Ch1Servlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { Save it to Servlet.java PrintWriter out = response.getWriter(); java.util.Date today = new java.util.Date(); out.println(“<html> “ + “<body>” + “<h1 align=center>HF’s Chapter1 Servlet</h1>” + “<br>” + today + “</body>” + “</html>”); } }
  • 18. Servlet: deploy (1) <?xml version=”1.0” encoding=”ISO-8851-1” ?> <web-app xmlns=”http://java.sun.com/xml/ns/j2ee” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd” version=”2.4”> <servlet> <servlet-name>Servlet</servlet-name> <servlet-class>Ch1Servlet</servlet-class> Save this </servlet> <servlet-mapping> <servlet-name>Servlet</servlet-name> <url-pattern>/Serv1</url-pattern> </servlet-mapping> </web-app> deployment descriptor (DD) to web.xml
  • 19. Servlet: deploy (2) Save your files in your file system
  • 20. Servlet: deploy (3) and use • • • • Compile Transfer to Tomcat’s file system Start Tomcat Click path in your browser
  • 21. But … • Stuff HTML as a string into java (println)? • Why not stuff Java into HTML (or XML)?
  • 23. What is a Container?
  • 24. What a Container offers? • Help you to concentrate on your business logic than programming details – Communication – Lifecycle Management – Multithreading Support – Declarative Security – JSP Support
  • 25. How the Container handles requests?
  • 26. Back to the code (servlet.java) import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Ch1Servlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { PrintWriter out = response.getWriter(); java.util.Date today = new java.util.Date(); out.println(“<html> “ + “<body>” + “<h1 align=center>HF’s Chapter1 Servlet</h1>” + “<br>” + today + “</body>” + “</html>”); } }
  • 27. Questions • Where service() comes from? • How the container finds the correct servlet? • Does the URL define where exactly the servlet is? • Possible answers – The user gives precise URL – The container’s tool does the mapping – We store the mapping to the properties table
  • 28. Three different names for a servlet
  • 30. Map URLs top Servlet with DD Deployment Descriptor (DD) has 2 elements <web-app ...> <servlet> <servlet-name>Internal name 1</servlet-name> <servlet-class>foo.Servlet1</servlet-class> </servlet> <servlet> <servlet-name>Internal name 2</servlet-name> <servlet-class>foo.Servlet2</servlet-class> </servlet> <servlet-mapping> <servlet-name>Internal name 1</servlet-name> <url-pattern>/Public1</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Internal name 2</servlet-name> <url-pattern>/Public2</url-pattern> </servlet-mapping> </web-app>
  • 31. Manipulate without touching with DD • Minimizes touching source code that has already been tested. • fine-tune your app’s capabilities, even if you don’t have the source code. • adapt your application to different resources (like databases), without having to recompile and test any code. • maintain dynamic security info like access control lists and security roles. • non-programmers may modify and deploy your web applications.