SlideShare a Scribd company logo
GOVERNMENT ARTS COLLEGE
Melur, Madurai
By
Mr. V. Veeranan
Roll No: P22PCS123
I M.Sc. Computer Science
Topic: Server Side Include
(Cookies and Filters)
PG. Department of Computer Science
ADVANCED JAVA PROGRAMMING
Server Side Includes (SSI)
Embed instructions to the Server
Inside an HTML document
HTML tag Language
A special file -> .shtml
SHTML -> the web server
Servlets
To add small of dynamic content
Otherwise static HTML pages
Server-side Includes(SSI)
 Server-Side Includes (SSI) give you the ability to embed
instructions to the server inside an HTML document.
 The instructions are given using extensions to the HTML tag
language. A special file extension,
 . shtml, signals the server that the document contains SSI directives.
 SHTML is a file extension that lets the web server know the file
should be processed as using Server Side Includes(SSI)
 Servlets are not confined to handling entire requests. Some web
servers allow servlets to add small amounts of dynamic content to
otherwise static HTML pages.
Server Side Include Tag
 A page that uses the advertisement servlet is written just like a normal
HTML page, except that it contains one or more <SERVILET> tags
and is saved with the .shtml extension.
• The <SERVIET> tag is similar to the <APPLET> tag, which loads an
applet within a page. When a client requests a .shtml page, the server
finds all of the <SERVLET> tags in the text and replaces them with the
output from the appropriate servlets.
• When you use a <SERVLET> tag, you must include a CODE parameter
that identifies the servlet to be loaded. This can be a class name or a
servlet allas set up within the server. On some servers, you can specify
an optional CODEBASE parameter that loads the servlet code from a
remote location.
Server Side Include
• Any additional parameters are treated as servlet initialization
parameters. Each <SERVLET> tag must be matched by a
closing</SERVLET> tag.
• Between the opening and closing tags, you can include as many
<PARAM> tags as necessary, where you specify NAME and
VALUE attributes for each one.
• The servlet can them access these parameters with getParameter().
Example (Time.shtml)
<HTML>
<HEAD> <TITLE> Times1</TITLE></HEAD>
<BODY>
The current time here is:
<SERVLET CODE=CurrentTime>
</SERVLET>
<p>
The current time in London is:
<SERVLET CODE
Cookies
• Cookies is a small text file containing client information sent by a
web server to a browser that can later be read back from the
browser.
• When a browser receives a cookie, it saves the cookie and there after
sends the cookie back to the server each time it accesses a page on
the server, subject to certain rules.
• Since cookie’s value can uniquely identify a client, cookies are often
used for session tracking.
• The browser is expected to support 20 cookies for each Web server,
300 cookies total any may limit cookie size to 4kb each.
Cookies
Working with Cookies
Cookies Methods
Working with Cookies
Create Cookie Class Constructor
public Cookie(String name, String Value())
Create Cookie, Send -> Browser
HttpServletResponce.addCookie(Cookie Cokie)
Servlet -> Request
HttpServletRequest.getCookies()
Cookie Methods
Specifies a Comment
public void setComment(java.lang.String purpose)
Comment using describing
public java.lang.String getComment()
Specifies the Domain name
public void setDomain(java.lang.String pattern)
The Maximum age -> Cookie
public void setMaxAge(int expiry)
Positive Vallue -> Negative value -> Zero Value
Return the Maximum age -> Cookie
public int setMaxAge()
Set of URIs -> Client
public void setPath(java.lang.String.url)
Cookie Methods
Returns the Paths
public java.lang.String.getPath()
Indicates to the Browser
public vaid setSecure(boolean flag)
Returns true if -> Browser -> Sending
public Boollean getSecure()
Filters
 Filter is a component which dynamically intercepts requests
and responses to transform or use the information contained
in the requests or response,
 Filters typically do not themselves create responses but
provide universal functions that can be “attached” to any
type of servlet or JSP page.
 A filter is a program that runs on the server before the servlet
with which it is associated.
Benefits of Filters
 Filters encapsulates common behaviour in a modular and
reusable manner.
 It separates high-level access decisions from presentation
code.
 It applies wholesale changes to many different resources.
Types/Components of Filters
Filters can perform many different types of functions. Based on
their functionalities following are the filters
 Authentication: Blocking requests based on user identity.
 Logging and auditing: Tracking users of a web application.
 Image conversion: Scaling maps and so on.
 Localization: Targeting the request and response to particular
locale.
 XSL/T Transformations of XML Content: Targeting web
application responses to more than one type of client.
Programming a Filter
 Create a class that implement the filter interface
 Put the filtering behaviour in the doFilter method
 Call the doFilter Method of the FilterChain object
 Register the filter with the appropriate servlets and JSP pages
 Disable the invoker servlet.
Filter Element in web.xml
 Icon
 Filter-name
 Display-name
 Description
 Filter-class
 Init-param
 Filter-Mapping Element
 Filter-name
 url-pattern
 Servlet-name
Process of Registering
Filter with Servlet
 One filter can be associated with more than one servlet.
 More than one filter can be mapped to a servlet.
 A filter can be mapped to all the servlet using an “*”.
 The filter, filter-mapping, serdfsdvlet and servlet-mapping
element must appear in the web application deployment
descriptor in that order.
Filter Life Cycle
 Methods Controlling life cycle of a filter are as follows
 init()
 doFilter()
 destroy()
 Three methods of Filter interface makes up the life cycle of a
filter.
 public void init(FilterConfig config) throws ServletException
 public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws ServletException, IOException
 public void destroy()
Thank You…

More Related Content

PPTX
CS8651 IP Unit 3.pptx
PPTX
IP UNIT III PPT.pptx
PDF
Bt0083 server side programing
PPTX
Cookies
PDF
07 cookies
PPTX
Cookies
PDF
Servlets
PPTX
Session tracking in servlets
CS8651 IP Unit 3.pptx
IP UNIT III PPT.pptx
Bt0083 server side programing
Cookies
07 cookies
Cookies
Servlets
Session tracking in servlets

Similar to GAC Java Presentation_Server Side Include_Cookies_Filters 2022.ppt (20)

PDF
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
PPT
Java - Servlet - Mazenet Solution
PDF
Adv java unit 4 M.Sc CS.pdf
PPTX
java Servlet technology
PPTX
Servlets-UNIT3and introduction to servlet
PDF
Servlet sessions
PPTX
UNIT - 5.pptx Servlets And Database Connectivity
PPTX
servlets sessions and cookies, jdbc connectivity
PPTX
SessionTrackServlets.pptx
PDF
Lecture 3: Servlets - Session Management
PPT
session and cookies.ppt
PPTX
Advance java session 7
PPTX
SCWCD : Servlet web applications : CHAP 3
PPTX
Session 5 - Working withAFTER Filters.pptx
PPTX
Servlets
ODP
Servlets
PPT
Session 3 inter-servlet communication & filters - Giáo trình Bách Khoa Aptech
PPT
Basics Of Servlet
PDF
spring Boot Tutorial Part 1(JPA&Hibernate)
PPT
W3 C11
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
Java - Servlet - Mazenet Solution
Adv java unit 4 M.Sc CS.pdf
java Servlet technology
Servlets-UNIT3and introduction to servlet
Servlet sessions
UNIT - 5.pptx Servlets And Database Connectivity
servlets sessions and cookies, jdbc connectivity
SessionTrackServlets.pptx
Lecture 3: Servlets - Session Management
session and cookies.ppt
Advance java session 7
SCWCD : Servlet web applications : CHAP 3
Session 5 - Working withAFTER Filters.pptx
Servlets
Servlets
Session 3 inter-servlet communication & filters - Giáo trình Bách Khoa Aptech
Basics Of Servlet
spring Boot Tutorial Part 1(JPA&Hibernate)
W3 C11
Ad

More from CUO VEERANAN VEERANAN (20)

PPT
Digital Logic Fundamentals – Number Systems & Codes
PPT
Cryptography - Unit I | Introduction to Security Concepts
PPT
Python Programming Unit II Control Statements.ppt
PPT
Python Programming Essentials – A Student-Friendly Approach.ppt
PPT
From Operators to Arrays – Power Up Your Python Skills for Real-World Coding!
PPT
Master Python Basics Easily – From Zero to Real-World Applications for UG Stu...
PDF
Banakacherla Project and Inter-State Water Politics in India
PPT
Overview of MS Access A Beginner's Guide to Creating and Managing Databases.ppt
PPT
HTML List, Nesting List & Hyperlinks.ppt
PPT
HTML Specific HTML tags also control font styles and colors
PPT
Introduction to Web Development Web Basics & HTML Tags
PPTX
Big Data - large Scale data (Amazon, FB)
PPTX
Fourier Transforms are indispensable tool
PPT
ENHANCING BIOLOGICAL RESEARCH THROUGH DIGITAL TECHNOLOGIES AND COMPUTATIONAL.ppt
PDF
ADS_Unit I_Route Map 2023.pdf
PPT
CS 23 Operating System Design Principles_MULTIPROCESSOR AND REAL TIME SCHEDULING
PPT
Python Unit I MCQ.ppt
PPT
GAC DS Priority Queue Presentation 2022.ppt
PDF
Lab 3 Python Programming Lab 8-15 MKU.pdf
PDF
Lab 3 Python Programming Lab 1-8 MKU.pdf
Digital Logic Fundamentals – Number Systems & Codes
Cryptography - Unit I | Introduction to Security Concepts
Python Programming Unit II Control Statements.ppt
Python Programming Essentials – A Student-Friendly Approach.ppt
From Operators to Arrays – Power Up Your Python Skills for Real-World Coding!
Master Python Basics Easily – From Zero to Real-World Applications for UG Stu...
Banakacherla Project and Inter-State Water Politics in India
Overview of MS Access A Beginner's Guide to Creating and Managing Databases.ppt
HTML List, Nesting List & Hyperlinks.ppt
HTML Specific HTML tags also control font styles and colors
Introduction to Web Development Web Basics & HTML Tags
Big Data - large Scale data (Amazon, FB)
Fourier Transforms are indispensable tool
ENHANCING BIOLOGICAL RESEARCH THROUGH DIGITAL TECHNOLOGIES AND COMPUTATIONAL.ppt
ADS_Unit I_Route Map 2023.pdf
CS 23 Operating System Design Principles_MULTIPROCESSOR AND REAL TIME SCHEDULING
Python Unit I MCQ.ppt
GAC DS Priority Queue Presentation 2022.ppt
Lab 3 Python Programming Lab 8-15 MKU.pdf
Lab 3 Python Programming Lab 1-8 MKU.pdf
Ad

Recently uploaded (20)

PDF
Pre independence Education in Inndia.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Computing-Curriculum for Schools in Ghana
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Classroom Observation Tools for Teachers
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
RMMM.pdf make it easy to upload and study
PPTX
Cell Structure & Organelles in detailed.
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pre independence Education in Inndia.pdf
Institutional Correction lecture only . . .
Microbial diseases, their pathogenesis and prophylaxis
Computing-Curriculum for Schools in Ghana
Module 4: Burden of Disease Tutorial Slides S2 2025
O5-L3 Freight Transport Ops (International) V1.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Classroom Observation Tools for Teachers
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Microbial disease of the cardiovascular and lymphatic systems
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
GDM (1) (1).pptx small presentation for students
Supply Chain Operations Speaking Notes -ICLT Program
RMMM.pdf make it easy to upload and study
Cell Structure & Organelles in detailed.
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Abdominal Access Techniques with Prof. Dr. R K Mishra

GAC Java Presentation_Server Side Include_Cookies_Filters 2022.ppt

  • 1. GOVERNMENT ARTS COLLEGE Melur, Madurai By Mr. V. Veeranan Roll No: P22PCS123 I M.Sc. Computer Science Topic: Server Side Include (Cookies and Filters) PG. Department of Computer Science ADVANCED JAVA PROGRAMMING
  • 2. Server Side Includes (SSI) Embed instructions to the Server Inside an HTML document HTML tag Language A special file -> .shtml SHTML -> the web server Servlets To add small of dynamic content Otherwise static HTML pages
  • 3. Server-side Includes(SSI)  Server-Side Includes (SSI) give you the ability to embed instructions to the server inside an HTML document.  The instructions are given using extensions to the HTML tag language. A special file extension,  . shtml, signals the server that the document contains SSI directives.  SHTML is a file extension that lets the web server know the file should be processed as using Server Side Includes(SSI)  Servlets are not confined to handling entire requests. Some web servers allow servlets to add small amounts of dynamic content to otherwise static HTML pages.
  • 4. Server Side Include Tag  A page that uses the advertisement servlet is written just like a normal HTML page, except that it contains one or more <SERVILET> tags and is saved with the .shtml extension. • The <SERVIET> tag is similar to the <APPLET> tag, which loads an applet within a page. When a client requests a .shtml page, the server finds all of the <SERVLET> tags in the text and replaces them with the output from the appropriate servlets. • When you use a <SERVLET> tag, you must include a CODE parameter that identifies the servlet to be loaded. This can be a class name or a servlet allas set up within the server. On some servers, you can specify an optional CODEBASE parameter that loads the servlet code from a remote location.
  • 5. Server Side Include • Any additional parameters are treated as servlet initialization parameters. Each <SERVLET> tag must be matched by a closing</SERVLET> tag. • Between the opening and closing tags, you can include as many <PARAM> tags as necessary, where you specify NAME and VALUE attributes for each one. • The servlet can them access these parameters with getParameter().
  • 6. Example (Time.shtml) <HTML> <HEAD> <TITLE> Times1</TITLE></HEAD> <BODY> The current time here is: <SERVLET CODE=CurrentTime> </SERVLET> <p> The current time in London is: <SERVLET CODE
  • 7. Cookies • Cookies is a small text file containing client information sent by a web server to a browser that can later be read back from the browser. • When a browser receives a cookie, it saves the cookie and there after sends the cookie back to the server each time it accesses a page on the server, subject to certain rules. • Since cookie’s value can uniquely identify a client, cookies are often used for session tracking. • The browser is expected to support 20 cookies for each Web server, 300 cookies total any may limit cookie size to 4kb each.
  • 9. Working with Cookies Create Cookie Class Constructor public Cookie(String name, String Value()) Create Cookie, Send -> Browser HttpServletResponce.addCookie(Cookie Cokie) Servlet -> Request HttpServletRequest.getCookies()
  • 10. Cookie Methods Specifies a Comment public void setComment(java.lang.String purpose) Comment using describing public java.lang.String getComment() Specifies the Domain name public void setDomain(java.lang.String pattern) The Maximum age -> Cookie public void setMaxAge(int expiry) Positive Vallue -> Negative value -> Zero Value Return the Maximum age -> Cookie public int setMaxAge() Set of URIs -> Client public void setPath(java.lang.String.url)
  • 11. Cookie Methods Returns the Paths public java.lang.String.getPath() Indicates to the Browser public vaid setSecure(boolean flag) Returns true if -> Browser -> Sending public Boollean getSecure()
  • 12. Filters  Filter is a component which dynamically intercepts requests and responses to transform or use the information contained in the requests or response,  Filters typically do not themselves create responses but provide universal functions that can be “attached” to any type of servlet or JSP page.  A filter is a program that runs on the server before the servlet with which it is associated.
  • 13. Benefits of Filters  Filters encapsulates common behaviour in a modular and reusable manner.  It separates high-level access decisions from presentation code.  It applies wholesale changes to many different resources.
  • 14. Types/Components of Filters Filters can perform many different types of functions. Based on their functionalities following are the filters  Authentication: Blocking requests based on user identity.  Logging and auditing: Tracking users of a web application.  Image conversion: Scaling maps and so on.  Localization: Targeting the request and response to particular locale.  XSL/T Transformations of XML Content: Targeting web application responses to more than one type of client.
  • 15. Programming a Filter  Create a class that implement the filter interface  Put the filtering behaviour in the doFilter method  Call the doFilter Method of the FilterChain object  Register the filter with the appropriate servlets and JSP pages  Disable the invoker servlet.
  • 16. Filter Element in web.xml  Icon  Filter-name  Display-name  Description  Filter-class  Init-param  Filter-Mapping Element  Filter-name  url-pattern  Servlet-name
  • 17. Process of Registering Filter with Servlet  One filter can be associated with more than one servlet.  More than one filter can be mapped to a servlet.  A filter can be mapped to all the servlet using an “*”.  The filter, filter-mapping, serdfsdvlet and servlet-mapping element must appear in the web application deployment descriptor in that order.
  • 18. Filter Life Cycle  Methods Controlling life cycle of a filter are as follows  init()  doFilter()  destroy()  Three methods of Filter interface makes up the life cycle of a filter.  public void init(FilterConfig config) throws ServletException  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException  public void destroy()

Editor's Notes

  • #2: Connected component