SlideShare a Scribd company logo
1 of 18
Chaper 1 Servlets / JSP Course Introduction to servlets
Servlet / JSP course topics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introduction to servlets
Introduction to servlets ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What Is a Servlet? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Servlet Life Cycle ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Servlet Life Cycle
Exercise 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise 1 Results ,[object Object]
Exercise 1 Results
Exercise 1 Results ,[object Object],< form   action = &quot; addToEmailList &quot;   method = &quot;post&quot; > < table   cellspacing = &quot;5&quot;   border = &quot;0&quot; > < tr > < td   align = &quot;right&quot; > First name: </ td > < td >< input   type = &quot;text&quot;   name = &quot;firstName&quot; ></ td > </ tr > < tr > < td   align = &quot;right&quot; > Last name: </ td > < td >< input   type = &quot;text&quot;   name = &quot;lastName&quot; ></ td > </ tr > < tr > < td   align = &quot;right&quot; > Email address: </ td > < td >< input   type = &quot;text&quot;   name = &quot;emailAddress&quot; ></ td > </ tr > < tr > < td ></ td > < td >< br >< input   type = &quot;submit&quot;   value = &quot;Submit&quot; ></ td > </ tr > </ table > </ form > The servlet mapped In the web.xml
Exercise 1 Results ,[object Object],. . .  protected   void  doPost( HttpServletRequest  request , HttpServletResponse  response )  throws  ServletException, IOException { // get parameters from the request String firstName =  request .getParameter( &quot;firstName&quot; ); String lastName =  request .getParameter( &quot;lastName&quot; ); String emailAddress =  request .getParameter( &quot;emailAddress&quot; ); // get a relative file name ServletContext sc = getServletContext(); String path = sc.getRealPath( &quot;/WEB-INF/EmailList.txt&quot; ); // use regular Java objects to write the data to a file User user =  new  User(firstName, lastName, emailAddress); UserIO. add (user, path); . . . The request & Response objects
Exercise 1 Results ,[object Object],. . .  // send response to browser response.setContentType( &quot;text/html;charset=UTF-8&quot; ); PrintWriter out = response.getWriter();  out.println( . . . +  &quot;  <table cellspacing=amp;quot;5amp;quot; cellpadding=amp;quot;5amp;quot; border=amp;quot;1amp;quot;>&quot; +  &quot;  <tr><td align=amp;quot;rightamp;quot;>First name:</td>&quot; +  &quot;  <td>&quot;  + firstName +  &quot;</td>&quot; +  &quot;  </tr>&quot; +  &quot;  <tr><td align=amp;quot;rightamp;quot;>Last name:</td>&quot; +  &quot;  <td>&quot;  + lastName +  &quot;</td>&quot; +  &quot;  </tr>&quot; +  &quot;  <tr><td align=amp;quot;rightamp;quot;>Email address:</td>&quot; +  &quot;  <td>&quot;  + emailAddress +  &quot;</td>&quot; +  &quot;  </tr>&quot; +  &quot;  </table>&quot; . . . out.close(); . . . The Response to The web client
Exercise 1 Results ,[object Object]
Methods provided by ServletRequest for retrieving client-sent parameters
Life-cycle Servlet Methods ,[object Object],[object Object],[object Object]
Example of Life-cycle Servlet Methods ,[object Object],. . .  public   class  AddToEmailListServlet2  extends  HttpServlet {  // declare an instance variable for the page int   globalCount ;  // instance variables are not thread-safe public   void   init ()  throws  ServletException { globalCount  = 0;  // initialize the instance variable } protected   void  doPost( HttpServletRequest request,  HttpServletResponse response)  throws  ServletException, IOException { // update global count variable globalCount ++;  // this is not thread-safe . . .
Resources To download example code for this chapter go to: http://www.jeetrainers.com

More Related Content

What's hot

Java Servlets
Java ServletsJava Servlets
Java Servlets
Nitin Pai
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
Jafar Nesargi
 
Core web application development
Core web application developmentCore web application development
Core web application development
Bahaa Farouk
 

What's hot (20)

Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
Servlets
ServletsServlets
Servlets
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jsp
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Java Servlet
Java Servlet Java Servlet
Java Servlet
 
Servlet ppt by vikas jagtap
Servlet ppt by vikas jagtapServlet ppt by vikas jagtap
Servlet ppt by vikas jagtap
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
 
Servlet
Servlet Servlet
Servlet
 
Java servlets
Java servletsJava servlets
Java servlets
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
Servlets
ServletsServlets
Servlets
 
Core web application development
Core web application developmentCore web application development
Core web application development
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
 
JEE Programming - 04 Java Servlets
JEE Programming - 04 Java ServletsJEE Programming - 04 Java Servlets
JEE Programming - 04 Java Servlets
 
Servlets
ServletsServlets
Servlets
 
Servlets
ServletsServlets
Servlets
 
Servlets
ServletsServlets
Servlets
 

Viewers also liked

Viewers also liked (19)

Servlet and JSP Lifecycle
Servlet and JSP LifecycleServlet and JSP Lifecycle
Servlet and JSP Lifecycle
 
DISCUS: Distributed Innovation and Scalable Collaboration in Uncertain Settings
DISCUS: Distributed Innovation and Scalable Collaboration in Uncertain SettingsDISCUS: Distributed Innovation and Scalable Collaboration in Uncertain Settings
DISCUS: Distributed Innovation and Scalable Collaboration in Uncertain Settings
 
서블릿(servlet)
서블릿(servlet)서블릿(servlet)
서블릿(servlet)
 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQuery
 
forensic document examiner using graphology science
forensic document examiner using graphology scienceforensic document examiner using graphology science
forensic document examiner using graphology science
 
Handwriting and Document Examination
Handwriting and Document ExaminationHandwriting and Document Examination
Handwriting and Document Examination
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
Jsp
JspJsp
Jsp
 
jQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksjQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & Tricks
 
Jsp (java server page)
Jsp (java server page)Jsp (java server page)
Jsp (java server page)
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
Java Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP BasicJava Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP Basic
 
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
 
Java server pages
Java server pagesJava server pages
Java server pages
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Jsp presentation
Jsp presentationJsp presentation
Jsp presentation
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 

Similar to Servlet/JSP course chapter 1: Introduction to servlets

Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
Sagar Nakul
 

Similar to Servlet/JSP course chapter 1: Introduction to servlets (20)

Servlet/JSP course chapter 2: Introduction to JavaServer Pages (JSP)
Servlet/JSP course chapter 2: Introduction to JavaServer Pages (JSP)Servlet/JSP course chapter 2: Introduction to JavaServer Pages (JSP)
Servlet/JSP course chapter 2: Introduction to JavaServer Pages (JSP)
 
C:\fakepath\jsp01
C:\fakepath\jsp01C:\fakepath\jsp01
C:\fakepath\jsp01
 
Jsp 01
Jsp 01Jsp 01
Jsp 01
 
29 Jsp
29 Jsp29 Jsp
29 Jsp
 
Servlet11
Servlet11Servlet11
Servlet11
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
 
Server-side Technologies in Java
Server-side Technologies in JavaServer-side Technologies in Java
Server-side Technologies in Java
 
Struts,Jsp,Servlet
Struts,Jsp,ServletStruts,Jsp,Servlet
Struts,Jsp,Servlet
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
 
Jsp
JspJsp
Jsp
 
Jsp Slides
Jsp SlidesJsp Slides
Jsp Slides
 
Lecture5
Lecture5Lecture5
Lecture5
 
SCWCD 2. servlet req - resp (cap3 - cap4)
SCWCD 2. servlet   req - resp (cap3 - cap4)SCWCD 2. servlet   req - resp (cap3 - cap4)
SCWCD 2. servlet req - resp (cap3 - cap4)
 
JAVA SERVER PAGES
JAVA SERVER PAGESJAVA SERVER PAGES
JAVA SERVER PAGES
 
Bt0083 server side programing 2
Bt0083 server side programing  2Bt0083 server side programing  2
Bt0083 server side programing 2
 
JSP diana y yo
JSP diana y yoJSP diana y yo
JSP diana y yo
 
Selenium
SeleniumSelenium
Selenium
 
Online grocery store
Online grocery storeOnline grocery store
Online grocery store
 

More from JavaEE Trainers (8)

Introduction tomcat7 servlet3
Introduction tomcat7 servlet3Introduction tomcat7 servlet3
Introduction tomcat7 servlet3
 
Introduction to java servlet 3.0 api javaone 2009
Introduction to java servlet 3.0 api javaone 2009Introduction to java servlet 3.0 api javaone 2009
Introduction to java servlet 3.0 api javaone 2009
 
Introduction to java servlet 3.0 api javaone 2008
Introduction to java servlet 3.0 api javaone 2008Introduction to java servlet 3.0 api javaone 2008
Introduction to java servlet 3.0 api javaone 2008
 
Jsp quick reference card
Jsp quick reference cardJsp quick reference card
Jsp quick reference card
 
jsp, javaserver pages, Card20
jsp, javaserver pages, Card20jsp, javaserver pages, Card20
jsp, javaserver pages, Card20
 
Struts2 course chapter 2: installation and configuration
Struts2 course chapter 2: installation and configurationStruts2 course chapter 2: installation and configuration
Struts2 course chapter 2: installation and configuration
 
Struts2 course chapter 1: Evolution of Web Applications
Struts2 course chapter 1: Evolution of Web ApplicationsStruts2 course chapter 1: Evolution of Web Applications
Struts2 course chapter 1: Evolution of Web Applications
 
Struts2 Course: Introduction
Struts2 Course: IntroductionStruts2 Course: Introduction
Struts2 Course: Introduction
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - 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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Servlet/JSP course chapter 1: Introduction to servlets

Editor's Notes

  1. &lt;iframe src=&amp;quot;http://rcm.amazon.com/e/cm?t=marcelblog-20&amp;o=1&amp;p=8&amp;l=as1&amp;asins=1932394389&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr&amp;quot; style=&amp;quot;width:120px;height:240px;&amp;quot; scrolling=&amp;quot;no&amp;quot; marginwidth=&amp;quot;0&amp;quot; marginheight=&amp;quot;0&amp;quot; frameborder=&amp;quot;0&amp;quot;&gt;&lt;/iframe&gt;