SlideShare a Scribd company logo
1 of 21
ServletsServlets
JSPJSP
ServletsServlets
Java Servletl ri web hiss d çalışma üstünlüyü yaradır.ə ə ə
HTTP client(Browser) v HTTP server arasında bir qat t şkilə ə
edir.
Java classının bütün öz llikl ri, HTTP request v HTTPə ə ə
response lav edilib.ə ə
İç risind h m java kod h m d HTML tag-lar yazmaq olur.ə ə ə ə ə
HTML kod PrintWriter.println() içind yazılır.ə
Servletl rin arxitekturasıəServletl rin arxitekturasıə
Java Server Pages ( JSP)Java Server Pages ( JSP)
JSP dinamik web s hif dirə ə
JSP sad HTML il azacıq Java kodun qarışımı say sində ə ə ə
yazılıb.
Java kod xüsusi tag iç risind yazılır. <% … %>ə ə
JSP s hif nin sonluğu (formatı) .jsp olmalıdır.ə ə
JSP kompilyasiya zamanı Java Servlet çevrilir.ə
Servlet / JSP Yaşam döngüsüServlet / JSP Yaşam döngüsü
Init
init jsp / servlet çağırılark n bir d f iş düşür.ə ə ə ə
Service
Bütün requestl rin keçdiyi bir metoddur.ə
Destroy
jsp / servlet-in yaşam döngüsünün sonunda bir d f işə ə ə
düşür.
JSP Tag-larJSP Tag-lar
<%=d y r %>ə ə
D y rl ri HTML-d göst rm k üçündür.ə ə ə ə ə ə
<% Java kod %> HTML iç risind Java kod yazmaqə ə
üçündür.
<%! … %> s hif açılark n statik d yiş nl r yaratmaqə ə ə ə ə ə
üçündür.
Nümun kodlarəNümun kodlarə
<html>
<body>
Tarix: <%=new java.util.Date() %>
</body>
</html>
Qeyd:
biz bugünün tarixini HTML-d göst rm k üçün <%= %> bu tag-dan istifad etdik.ə ə ə ə
java.util.Date() v zin Date() yaza bil rik ancaq bunun üçün import lazımdır növb tiə ə ə ə ə
s hif d toxunacağıq.ə ə ə
Scriptletl rəScriptletl rə
Scriptletl r <% … %> bu tag içind olur.ə ə
Scriptletl r HTML için yazılan java kodlardır.ə ə
Nümun :ə
<% if(Math.random()<3){ %>
<p> 3-d n kiçikdir</p>ə
<% }else{ %>
<p>3-d n böyükdür</p>ə
<% } %>
DeclarationlarDeclarationlar
Declarationlar üçün <%! … %> tag-ından sitifad olunur.ə
Nümun :ə
<HTML>
<BODY>
<%!
Date theDate = new java.util.Date();
Date getDate()
{
System.out.println( "In getDate() method" );
return theDate;
}
%>
indiki vaxt: <%= getDate() %>
</BODY>
</HTML>
JSP CommentsJSP Comments
JSP commentl r HTML comentl rd n f rql nir.ə ə ə ə ə
HTML commentl r client t r fd görünür.ə ə ə ə ə
<!— Bu HTML comentidir —>
JSP comment kodların dokumentasiyası üçündür.
JSP comment client t r fd görünmür.ə ə ə
<%— Bu JSP commentdir —%>
Directive-l rəDirective-l rə
<%@ page … %>
Bu tag-ın müxt lif atributları vardır. Daha çoxə
errorPage, contentType, pageEncoding atributları
istifad olunur.ə
<%@page errorPage="error-404.jsp"
contentType="text/html"
pageEncoding=“UTF-8"%>
<%@ include … %>
Bir atributu var “file”. M qs di h r hansı jsp və ə ə ə
ya html s hif ni s hif için lav etm kdir.ə ə ə ə ə ə ə ə
<%@include file="index.jsp" %>
<%@ taglib … %>
JSTL tag-ları import etm k üçündür.ə
JSP Default Object-l rəJSP Default Object-l rə
request: HttpServletRequest.
response: HttpServletResponse.
session: HttpSession.
out: JspWriter (PrintWriter-in eynisi).
application: t tbiqiniz var olduqca var.ə
exception: S hvl ri göst rir.ə ə ə
Nümun l rə əNümun l rə ə
Request
request.getParameter(“name”);
request.getRequestURI();
Response
response.sendRedirect(“https://google.az”);
response.setHeader(“Cache-Control”, “no-cache”);
response.setContentType(“text/html”);
JSP Session ObjectJSP Session Object
Session unique dataları client-in maşınında cookie kimi saxlayır
Session növl riə
Session Object
Cookies
Hidden Form Fields
URL Rewriting
NümunəNümunə
Sessiona d y r verm kə ə ə
session.setAttribute(“ad”, “d y r”);ə ə
Sessiondan d y r götürm kə ə ə
session.getAttribute(“ad”);
Sessiondan d y r silm kə ə ə
session.removeAttribute(“ad”);
JSP Application ObjectJSP Application Object
<% Integer hitsCount = (Integer)application.getAttribute(“hitCounter");
if( hitsCount ==null || hitsCount == 0 ){ out.println("Welcome to my
website!"); HitsCount = 1;
}else{
out.println("Welcome back to my website!"); hitsCount += 1;
} application.setAttribute("hitCounter", hitsCount); %> <p>Sayta ümumi
girişl rin sayı: <%= hitsCount%></p>ə
Lazımlı linkl rəLazımlı linkl rə
http://www.tutorialspoint.com/jsp/index.htm
http://www.tutorialspoint.com/servlets/index.htm
http://www.roseindia.net/jsp/jsp.htm
–Vüqar Süleymanov
“Suallarınız?”
T ş kkürl r!!!ə ə əT ş kkürl r!!!ə ə ə

More Related Content

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Servlet and jsp presentation

  • 2. ServletsServlets Java Servletl ri web hiss d çalışma üstünlüyü yaradır.ə ə ə HTTP client(Browser) v HTTP server arasında bir qat t şkilə ə edir. Java classının bütün öz llikl ri, HTTP request v HTTPə ə ə response lav edilib.ə ə İç risind h m java kod h m d HTML tag-lar yazmaq olur.ə ə ə ə ə HTML kod PrintWriter.println() içind yazılır.ə
  • 4. Java Server Pages ( JSP)Java Server Pages ( JSP) JSP dinamik web s hif dirə ə JSP sad HTML il azacıq Java kodun qarışımı say sində ə ə ə yazılıb. Java kod xüsusi tag iç risind yazılır. <% … %>ə ə JSP s hif nin sonluğu (formatı) .jsp olmalıdır.ə ə JSP kompilyasiya zamanı Java Servlet çevrilir.ə
  • 5. Servlet / JSP Yaşam döngüsüServlet / JSP Yaşam döngüsü Init init jsp / servlet çağırılark n bir d f iş düşür.ə ə ə ə Service Bütün requestl rin keçdiyi bir metoddur.ə Destroy jsp / servlet-in yaşam döngüsünün sonunda bir d f işə ə ə düşür.
  • 6. JSP Tag-larJSP Tag-lar <%=d y r %>ə ə D y rl ri HTML-d göst rm k üçündür.ə ə ə ə ə ə <% Java kod %> HTML iç risind Java kod yazmaqə ə üçündür. <%! … %> s hif açılark n statik d yiş nl r yaratmaqə ə ə ə ə ə üçündür.
  • 7. Nümun kodlarəNümun kodlarə <html> <body> Tarix: <%=new java.util.Date() %> </body> </html> Qeyd: biz bugünün tarixini HTML-d göst rm k üçün <%= %> bu tag-dan istifad etdik.ə ə ə ə java.util.Date() v zin Date() yaza bil rik ancaq bunun üçün import lazımdır növb tiə ə ə ə ə s hif d toxunacağıq.ə ə ə
  • 8. Scriptletl rəScriptletl rə Scriptletl r <% … %> bu tag içind olur.ə ə Scriptletl r HTML için yazılan java kodlardır.ə ə Nümun :ə <% if(Math.random()<3){ %> <p> 3-d n kiçikdir</p>ə <% }else{ %> <p>3-d n böyükdür</p>ə <% } %>
  • 9. DeclarationlarDeclarationlar Declarationlar üçün <%! … %> tag-ından sitifad olunur.ə Nümun :ə <HTML> <BODY> <%! Date theDate = new java.util.Date(); Date getDate() { System.out.println( "In getDate() method" ); return theDate; } %> indiki vaxt: <%= getDate() %> </BODY> </HTML>
  • 10. JSP CommentsJSP Comments JSP commentl r HTML comentl rd n f rql nir.ə ə ə ə ə HTML commentl r client t r fd görünür.ə ə ə ə ə <!— Bu HTML comentidir —> JSP comment kodların dokumentasiyası üçündür. JSP comment client t r fd görünmür.ə ə ə <%— Bu JSP commentdir —%>
  • 11. Directive-l rəDirective-l rə <%@ page … %> Bu tag-ın müxt lif atributları vardır. Daha çoxə errorPage, contentType, pageEncoding atributları istifad olunur.ə <%@page errorPage="error-404.jsp" contentType="text/html" pageEncoding=“UTF-8"%>
  • 12. <%@ include … %> Bir atributu var “file”. M qs di h r hansı jsp və ə ə ə ya html s hif ni s hif için lav etm kdir.ə ə ə ə ə ə ə ə <%@include file="index.jsp" %>
  • 13. <%@ taglib … %> JSTL tag-ları import etm k üçündür.ə
  • 14. JSP Default Object-l rəJSP Default Object-l rə request: HttpServletRequest. response: HttpServletResponse. session: HttpSession. out: JspWriter (PrintWriter-in eynisi). application: t tbiqiniz var olduqca var.ə exception: S hvl ri göst rir.ə ə ə
  • 15. Nümun l rə əNümun l rə ə Request request.getParameter(“name”); request.getRequestURI(); Response response.sendRedirect(“https://google.az”); response.setHeader(“Cache-Control”, “no-cache”); response.setContentType(“text/html”);
  • 16. JSP Session ObjectJSP Session Object Session unique dataları client-in maşınında cookie kimi saxlayır Session növl riə Session Object Cookies Hidden Form Fields URL Rewriting
  • 17. NümunəNümunə Sessiona d y r verm kə ə ə session.setAttribute(“ad”, “d y r”);ə ə Sessiondan d y r götürm kə ə ə session.getAttribute(“ad”); Sessiondan d y r silm kə ə ə session.removeAttribute(“ad”);
  • 18. JSP Application ObjectJSP Application Object <% Integer hitsCount = (Integer)application.getAttribute(“hitCounter"); if( hitsCount ==null || hitsCount == 0 ){ out.println("Welcome to my website!"); HitsCount = 1; }else{ out.println("Welcome back to my website!"); hitsCount += 1; } application.setAttribute("hitCounter", hitsCount); %> <p>Sayta ümumi girişl rin sayı: <%= hitsCount%></p>ə
  • 19. Lazımlı linkl rəLazımlı linkl rə http://www.tutorialspoint.com/jsp/index.htm http://www.tutorialspoint.com/servlets/index.htm http://www.roseindia.net/jsp/jsp.htm
  • 21. T ş kkürl r!!!ə ə əT ş kkürl r!!!ə ə ə