SlideShare a Scribd company logo
1 of 26
Servlets
By
Sharmilee J
Java Trainer
Mazenet Solution
ServletConfig
Servlet config Interface
• An object of ServletConfig is created by the web
container for each servlet.
• This object can be used to get configuration
information from web.xml file
Advantage:
• No need to update in web.xml if any changes
occurs.
Method:
getServletConfig()
Syntax: public ServletConfig getServletConfig();
<web-app>
<servlet>
<init-param>
<param-name>parametername</param-name>
<param-value>parametervalue</param-value>
</init-param>
</servlet>
</web-app>
ServletContext
ServletContext Interface
• An object of ServletContext is created by the
web container at time of deploying the project
• <context-param>element is used
Method:
getServletContext() method of ServletConfig
interface returns the object of ServletContext.
Syntax:
public ServletContext getServletContext()
<web-app>
......
<context-param>
<param-name>parametername</param-name>
<param-value>parametervalue</param-value>
</context-param>
......
</web-app>
Diff between ServletConfig & ServletContext
ServletConfig ServletContext
ServletConfig available
in javax.servlet.*; package
ServletContext available in
javax.servlet.*; package
ServletConfig object is one per servlet
class
ServletContext object is global to
entire web application
Object of ServletConfig will be created
during initialization process of the
servlet
Object of ServletContext will be
created at the time of web
application deployment
Scope: As long as a servlet is
executing, ServletConfig object will be
available, it will be destroyed once the
servlet execution is completed.
Scope: As long as web application is
executing, ServletContext object will
be available, and it will be destroyed
once the application is removed from
the server.
We should give request explicitly, in
order to create ServletConfig object for
the first time
ServletContext object will be available
even before giving the first request
In web.xml – <init-param> tag will be
appear under <servlet-class> tag
In web.xml – <context-param> tag will
be appear under <web-app> tag
Session Tracking
Session Tracking
• Session refers a particular interval of time.
• Session tracking is used to maintain the state
of an user. It is known as session management.
Session Tracking Techniques:
There are four techniques used in Session
tracking:
• Cookies
• Hidden Form Field
• URL Rewriting
• HttpSession
1. cookies
Cookies
• It is a piece of information.
• In cookies, request from same client is not
considered as the new request.
Types of cookies.
1. Non-Persistent cookie.
Valid for single session
2.Persistent cookie.
Valid for multiple session.
Advantage of Cookies:
• State maintenance
Disadvantages:
• Cookie can be disabled from the browser.
• Only textual information can be set.
Cookie creation:
• Cookie ck=new Cookie("user","sonoo jaiswal");
//creating cookie object
• response.addCookie(ck);
//adding cookie in the response
Cookie deletion:
• Cookie ck=new Cookie("user","");
//deleting value of cookie
• ck.setMaxAge(0);
//changing the maximum age to 0 seconds
• response.addCookie(ck);
//adding cookie in the response
2. Hidden Form Field
Hidden Form field
• We store the information in the hidden field
and get it from another servlet.
<input type="hidden" name="uname" value=“java">
Advantage:
• Work when the cookie is disabled.
Disadvantages:
• Only textual information can be sent.
• Maintained at server side.
3. URL Rewriting
URL Rewriting
• Appending session ID to the url is known as
url Rewriting.
• We implement url rewriting by caling,
response.encodeURL(String url);
Advantage:
• Work when the cookie is disabled.
• No form submission is not required as in case
of hidden form field.
4. HTTP Session
Http Session
• Used to view and manipulate information
about a session, such as the session identifier,
creation time, and last accessed time.
• HttpSession session=request.getSession();
Servlet Filters
Servlet Filters
• A filter is an object that is invoked at the
preprocessing and postprocessing of a request.
• servlet filter is pluggable, i.e if we remove filter in
web.xml, filter is automatically removed.
Advantage
• Encryption and decryption
• Input validation
• Recording all incoming requests
Filter API
Three interfaces:
• Filter
• FilterChain
• FilterConfig
Filter interface life cycle methods:
1.init(filterConfig)
2.doFilter(ServletRequest,ServletResponse,FilterChain)
3.destroy()
FilterConfig interface life cycle methods:
1.getInitParameter()
2.getInitParameterNames()
3.getServletContext()
4.getFilterName()
FilterChain interface life cycle method:
1.doFilter(ServletRequest,ServletResponse)
Java - Servlet - Mazenet Solution

More Related Content

What's hot

What's hot (20)

Servlets
ServletsServlets
Servlets
 
An Introduction To Java Web Technology
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technology
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
 
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
 
Servlets
ServletsServlets
Servlets
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Servlet
Servlet Servlet
Servlet
 
Servlets
ServletsServlets
Servlets
 
Servlets
ServletsServlets
Servlets
 
Session And Cookies In Servlets - Java
Session And Cookies In Servlets - JavaSession And Cookies In Servlets - Java
Session And Cookies In Servlets - Java
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Servlet lifecycle
Servlet lifecycleServlet lifecycle
Servlet lifecycle
 
Knowledge Sharing : Java Servlet
Knowledge Sharing : Java ServletKnowledge Sharing : Java Servlet
Knowledge Sharing : Java Servlet
 
Programming Server side with Sevlet
 Programming Server side with Sevlet  Programming Server side with Sevlet
Programming Server side with Sevlet
 
Servlets
ServletsServlets
Servlets
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
 
Core web application development
Core web application developmentCore web application development
Core web application development
 
Java servlets
Java servletsJava servlets
Java servlets
 
JEE Programming - 04 Java Servlets
JEE Programming - 04 Java ServletsJEE Programming - 04 Java Servlets
JEE Programming - 04 Java Servlets
 

Similar to Java - Servlet - Mazenet Solution

Adv java unit 4 M.Sc CS.pdf
Adv java unit 4 M.Sc CS.pdfAdv java unit 4 M.Sc CS.pdf
Adv java unit 4 M.Sc CS.pdfKALAISELVI P
 
SessionTrackServlets.pptx
SessionTrackServlets.pptxSessionTrackServlets.pptx
SessionTrackServlets.pptxRanjeet Reddy
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Roy de Kleijn
 
session and cookies.ppt
session and cookies.pptsession and cookies.ppt
session and cookies.pptJayaprasanna4
 
19_JavaScript - Storage_Cookies_students.pptx
19_JavaScript - Storage_Cookies_students.pptx19_JavaScript - Storage_Cookies_students.pptx
19_JavaScript - Storage_Cookies_students.pptxVatsalJain39
 
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 Connectivitypkaviya
 
J2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environmentJ2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environmentjoearunraja2
 
Advance java session 7
Advance java session 7Advance java session 7
Advance java session 7Smita B Kumar
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servletsvishal choudhary
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing Techglyphs
 
IP UNIT III PPT.pptx
 IP UNIT III PPT.pptx IP UNIT III PPT.pptx
IP UNIT III PPT.pptxssuser92282c
 
Integrating Servlets and JSP (The MVC Architecture)
Integrating Servlets and JSP  (The MVC Architecture)Integrating Servlets and JSP  (The MVC Architecture)
Integrating Servlets and JSP (The MVC Architecture)Amit Ranjan
 
Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: ServletsFahad Golra
 
Enterprise java unit-2_chapter-3
Enterprise  java unit-2_chapter-3Enterprise  java unit-2_chapter-3
Enterprise java unit-2_chapter-3sandeep54552
 

Similar to Java - Servlet - Mazenet Solution (20)

Adv java unit 4 M.Sc CS.pdf
Adv java unit 4 M.Sc CS.pdfAdv java unit 4 M.Sc CS.pdf
Adv java unit 4 M.Sc CS.pdf
 
SessionTrackServlets.pptx
SessionTrackServlets.pptxSessionTrackServlets.pptx
SessionTrackServlets.pptx
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
 
session and cookies.ppt
session and cookies.pptsession and cookies.ppt
session and cookies.ppt
 
Ecom2
Ecom2Ecom2
Ecom2
 
19_JavaScript - Storage_Cookies_students.pptx
19_JavaScript - Storage_Cookies_students.pptx19_JavaScript - Storage_Cookies_students.pptx
19_JavaScript - Storage_Cookies_students.pptx
 
Chapter 8 part1
Chapter 8   part1Chapter 8   part1
Chapter 8 part1
 
CS8651 IP Unit 3.pptx
CS8651 IP Unit 3.pptxCS8651 IP Unit 3.pptx
CS8651 IP Unit 3.pptx
 
ASP.NET-Web Programming - Sessions and Cookies
ASP.NET-Web Programming - Sessions and CookiesASP.NET-Web Programming - Sessions and Cookies
ASP.NET-Web Programming - Sessions and Cookies
 
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
 
J2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environmentJ2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environment
 
Advance java session 7
Advance java session 7Advance java session 7
Advance java session 7
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servlets
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing
 
IP UNIT III PPT.pptx
 IP UNIT III PPT.pptx IP UNIT III PPT.pptx
IP UNIT III PPT.pptx
 
Integrating Servlets and JSP (The MVC Architecture)
Integrating Servlets and JSP  (The MVC Architecture)Integrating Servlets and JSP  (The MVC Architecture)
Integrating Servlets and JSP (The MVC Architecture)
 
Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: Servlets
 
Enterprise java unit-2_chapter-3
Enterprise  java unit-2_chapter-3Enterprise  java unit-2_chapter-3
Enterprise java unit-2_chapter-3
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 

More from Mazenetsolution

Tally Auto E-mail Module | Mazenet Technologies
Tally Auto E-mail Module | Mazenet TechnologiesTally Auto E-mail Module | Mazenet Technologies
Tally Auto E-mail Module | Mazenet TechnologiesMazenetsolution
 
Tally Auto SMS Module| Mazenet Technologies
Tally Auto SMS  Module| Mazenet TechnologiesTally Auto SMS  Module| Mazenet Technologies
Tally Auto SMS Module| Mazenet TechnologiesMazenetsolution
 
Tally auto synchronization
Tally auto synchronization Tally auto synchronization
Tally auto synchronization Mazenetsolution
 
Print barcode using voucher- Mazenettechnologies
Print barcode using voucher- MazenettechnologiesPrint barcode using voucher- Mazenettechnologies
Print barcode using voucher- MazenettechnologiesMazenetsolution
 
Copy user list | Tally | Tally Software | Accounting Software | Mazenet
Copy user list | Tally | Tally Software | Accounting Software | MazenetCopy user list | Tally | Tally Software | Accounting Software | Mazenet
Copy user list | Tally | Tally Software | Accounting Software | MazenetMazenetsolution
 
Auto synchronization | Tally Software | Mazenet Technologies
Auto synchronization | Tally Software | Mazenet TechnologiesAuto synchronization | Tally Software | Mazenet Technologies
Auto synchronization | Tally Software | Mazenet TechnologiesMazenetsolution
 
Auto backup | Tally Coimbatore | Tally Software
Auto backup | Tally Coimbatore | Tally SoftwareAuto backup | Tally Coimbatore | Tally Software
Auto backup | Tally Coimbatore | Tally SoftwareMazenetsolution
 
Mazenet Technologies-Tally
Mazenet Technologies-TallyMazenet Technologies-Tally
Mazenet Technologies-TallyMazenetsolution
 
Android - Intents - Mazenet Solution
Android - Intents - Mazenet SolutionAndroid - Intents - Mazenet Solution
Android - Intents - Mazenet SolutionMazenetsolution
 
Software Testing - Tool support for testing (CAST) - Mazenet Solution
Software Testing - Tool support for testing (CAST) - Mazenet SolutionSoftware Testing - Tool support for testing (CAST) - Mazenet Solution
Software Testing - Tool support for testing (CAST) - Mazenet SolutionMazenetsolution
 
Software Testing - Test management - Mazenet Solution
Software Testing - Test management - Mazenet SolutionSoftware Testing - Test management - Mazenet Solution
Software Testing - Test management - Mazenet SolutionMazenetsolution
 
Red Hat - LVM - Mazenet Solution
Red Hat - LVM - Mazenet SolutionRed Hat - LVM - Mazenet Solution
Red Hat - LVM - Mazenet SolutionMazenetsolution
 
PHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet SolutionPHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet SolutionMazenetsolution
 
Static testing techniques
Static testing techniquesStatic testing techniques
Static testing techniquesMazenetsolution
 
Java- GUI- Mazenet solution
Java- GUI- Mazenet solutionJava- GUI- Mazenet solution
Java- GUI- Mazenet solutionMazenetsolution
 
Oracle- Introduction to Sql commands- Mazenet solution
Oracle- Introduction to Sql commands- Mazenet solutionOracle- Introduction to Sql commands- Mazenet solution
Oracle- Introduction to Sql commands- Mazenet solutionMazenetsolution
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linuxMazenetsolution
 
Software Testing- Principles of testing- Mazenet Solution
Software Testing- Principles of testing- Mazenet SolutionSoftware Testing- Principles of testing- Mazenet Solution
Software Testing- Principles of testing- Mazenet SolutionMazenetsolution
 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionMazenetsolution
 
Software Testing-Dynamic testing technique-Mazenet solution
Software Testing-Dynamic testing technique-Mazenet solutionSoftware Testing-Dynamic testing technique-Mazenet solution
Software Testing-Dynamic testing technique-Mazenet solutionMazenetsolution
 

More from Mazenetsolution (20)

Tally Auto E-mail Module | Mazenet Technologies
Tally Auto E-mail Module | Mazenet TechnologiesTally Auto E-mail Module | Mazenet Technologies
Tally Auto E-mail Module | Mazenet Technologies
 
Tally Auto SMS Module| Mazenet Technologies
Tally Auto SMS  Module| Mazenet TechnologiesTally Auto SMS  Module| Mazenet Technologies
Tally Auto SMS Module| Mazenet Technologies
 
Tally auto synchronization
Tally auto synchronization Tally auto synchronization
Tally auto synchronization
 
Print barcode using voucher- Mazenettechnologies
Print barcode using voucher- MazenettechnologiesPrint barcode using voucher- Mazenettechnologies
Print barcode using voucher- Mazenettechnologies
 
Copy user list | Tally | Tally Software | Accounting Software | Mazenet
Copy user list | Tally | Tally Software | Accounting Software | MazenetCopy user list | Tally | Tally Software | Accounting Software | Mazenet
Copy user list | Tally | Tally Software | Accounting Software | Mazenet
 
Auto synchronization | Tally Software | Mazenet Technologies
Auto synchronization | Tally Software | Mazenet TechnologiesAuto synchronization | Tally Software | Mazenet Technologies
Auto synchronization | Tally Software | Mazenet Technologies
 
Auto backup | Tally Coimbatore | Tally Software
Auto backup | Tally Coimbatore | Tally SoftwareAuto backup | Tally Coimbatore | Tally Software
Auto backup | Tally Coimbatore | Tally Software
 
Mazenet Technologies-Tally
Mazenet Technologies-TallyMazenet Technologies-Tally
Mazenet Technologies-Tally
 
Android - Intents - Mazenet Solution
Android - Intents - Mazenet SolutionAndroid - Intents - Mazenet Solution
Android - Intents - Mazenet Solution
 
Software Testing - Tool support for testing (CAST) - Mazenet Solution
Software Testing - Tool support for testing (CAST) - Mazenet SolutionSoftware Testing - Tool support for testing (CAST) - Mazenet Solution
Software Testing - Tool support for testing (CAST) - Mazenet Solution
 
Software Testing - Test management - Mazenet Solution
Software Testing - Test management - Mazenet SolutionSoftware Testing - Test management - Mazenet Solution
Software Testing - Test management - Mazenet Solution
 
Red Hat - LVM - Mazenet Solution
Red Hat - LVM - Mazenet SolutionRed Hat - LVM - Mazenet Solution
Red Hat - LVM - Mazenet Solution
 
PHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet SolutionPHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet Solution
 
Static testing techniques
Static testing techniquesStatic testing techniques
Static testing techniques
 
Java- GUI- Mazenet solution
Java- GUI- Mazenet solutionJava- GUI- Mazenet solution
Java- GUI- Mazenet solution
 
Oracle- Introduction to Sql commands- Mazenet solution
Oracle- Introduction to Sql commands- Mazenet solutionOracle- Introduction to Sql commands- Mazenet solution
Oracle- Introduction to Sql commands- Mazenet solution
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linux
 
Software Testing- Principles of testing- Mazenet Solution
Software Testing- Principles of testing- Mazenet SolutionSoftware Testing- Principles of testing- Mazenet Solution
Software Testing- Principles of testing- Mazenet Solution
 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet Solution
 
Software Testing-Dynamic testing technique-Mazenet solution
Software Testing-Dynamic testing technique-Mazenet solutionSoftware Testing-Dynamic testing technique-Mazenet solution
Software Testing-Dynamic testing technique-Mazenet solution
 

Recently uploaded

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).pdfSoniaTolstoy
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
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.pdfQucHHunhnh
 
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.pptxheathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
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
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
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
 
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
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

Java - Servlet - Mazenet Solution

  • 3. Servlet config Interface • An object of ServletConfig is created by the web container for each servlet. • This object can be used to get configuration information from web.xml file Advantage: • No need to update in web.xml if any changes occurs. Method: getServletConfig()
  • 4. Syntax: public ServletConfig getServletConfig(); <web-app> <servlet> <init-param> <param-name>parametername</param-name> <param-value>parametervalue</param-value> </init-param> </servlet> </web-app>
  • 6. ServletContext Interface • An object of ServletContext is created by the web container at time of deploying the project • <context-param>element is used Method: getServletContext() method of ServletConfig interface returns the object of ServletContext. Syntax: public ServletContext getServletContext()
  • 8. Diff between ServletConfig & ServletContext ServletConfig ServletContext ServletConfig available in javax.servlet.*; package ServletContext available in javax.servlet.*; package ServletConfig object is one per servlet class ServletContext object is global to entire web application Object of ServletConfig will be created during initialization process of the servlet Object of ServletContext will be created at the time of web application deployment Scope: As long as a servlet is executing, ServletConfig object will be available, it will be destroyed once the servlet execution is completed. Scope: As long as web application is executing, ServletContext object will be available, and it will be destroyed once the application is removed from the server. We should give request explicitly, in order to create ServletConfig object for the first time ServletContext object will be available even before giving the first request In web.xml – <init-param> tag will be appear under <servlet-class> tag In web.xml – <context-param> tag will be appear under <web-app> tag
  • 10. Session Tracking • Session refers a particular interval of time. • Session tracking is used to maintain the state of an user. It is known as session management.
  • 11. Session Tracking Techniques: There are four techniques used in Session tracking: • Cookies • Hidden Form Field • URL Rewriting • HttpSession
  • 13. Cookies • It is a piece of information. • In cookies, request from same client is not considered as the new request.
  • 14. Types of cookies. 1. Non-Persistent cookie. Valid for single session 2.Persistent cookie. Valid for multiple session. Advantage of Cookies: • State maintenance Disadvantages: • Cookie can be disabled from the browser. • Only textual information can be set.
  • 15. Cookie creation: • Cookie ck=new Cookie("user","sonoo jaiswal"); //creating cookie object • response.addCookie(ck); //adding cookie in the response Cookie deletion: • Cookie ck=new Cookie("user",""); //deleting value of cookie • ck.setMaxAge(0); //changing the maximum age to 0 seconds • response.addCookie(ck); //adding cookie in the response
  • 16. 2. Hidden Form Field
  • 17. Hidden Form field • We store the information in the hidden field and get it from another servlet. <input type="hidden" name="uname" value=“java"> Advantage: • Work when the cookie is disabled. Disadvantages: • Only textual information can be sent. • Maintained at server side.
  • 19. URL Rewriting • Appending session ID to the url is known as url Rewriting. • We implement url rewriting by caling, response.encodeURL(String url); Advantage: • Work when the cookie is disabled. • No form submission is not required as in case of hidden form field.
  • 21. Http Session • Used to view and manipulate information about a session, such as the session identifier, creation time, and last accessed time. • HttpSession session=request.getSession();
  • 23. Servlet Filters • A filter is an object that is invoked at the preprocessing and postprocessing of a request. • servlet filter is pluggable, i.e if we remove filter in web.xml, filter is automatically removed. Advantage • Encryption and decryption • Input validation • Recording all incoming requests
  • 24. Filter API Three interfaces: • Filter • FilterChain • FilterConfig Filter interface life cycle methods: 1.init(filterConfig) 2.doFilter(ServletRequest,ServletResponse,FilterChain) 3.destroy()
  • 25. FilterConfig interface life cycle methods: 1.getInitParameter() 2.getInitParameterNames() 3.getServletContext() 4.getFilterName() FilterChain interface life cycle method: 1.doFilter(ServletRequest,ServletResponse)