🗊Презентация Java Server Pages

Нажмите для полного просмотра!
Java Server Pages, слайд №1Java Server Pages, слайд №2Java Server Pages, слайд №3Java Server Pages, слайд №4Java Server Pages, слайд №5Java Server Pages, слайд №6Java Server Pages, слайд №7Java Server Pages, слайд №8Java Server Pages, слайд №9Java Server Pages, слайд №10Java Server Pages, слайд №11Java Server Pages, слайд №12Java Server Pages, слайд №13Java Server Pages, слайд №14Java Server Pages, слайд №15Java Server Pages, слайд №16Java Server Pages, слайд №17Java Server Pages, слайд №18Java Server Pages, слайд №19Java Server Pages, слайд №20Java Server Pages, слайд №21Java Server Pages, слайд №22Java Server Pages, слайд №23Java Server Pages, слайд №24Java Server Pages, слайд №25Java Server Pages, слайд №26Java Server Pages, слайд №27Java Server Pages, слайд №28Java Server Pages, слайд №29Java Server Pages, слайд №30Java Server Pages, слайд №31Java Server Pages, слайд №32Java Server Pages, слайд №33Java Server Pages, слайд №34

Вы можете ознакомиться и скачать презентацию на тему Java Server Pages. Доклад-сообщение содержит 34 слайдов. Презентации для любого класса можно скачать бесплатно. Если материал и наш сайт презентаций Mypresentation Вам понравились – поделитесь им с друзьями с помощью социальных кнопок и добавьте в закладки в своем браузере.

Слайды и текст этой презентации


Слайд 1





Java 4 WEB 
Lesson 13 – Java Server Pages
Описание слайда:
Java 4 WEB Lesson 13 – Java Server Pages

Слайд 2





Lesson goals
Why not servlets
What if not servlets 
Expression Language
Tag Libraries
Описание слайда:
Lesson goals Why not servlets What if not servlets Expression Language Tag Libraries

Слайд 3





Servlet drawbacks
Not simple to maintain - business logic mixed with presentation logic
Slow development - servlet code needs to be updated and recompiled if we have to change the look of the application.
Too much non-reusable copy-paste
Servlet can be viewed as "HTML inside Java"
Описание слайда:
Servlet drawbacks Not simple to maintain - business logic mixed with presentation logic Slow development - servlet code needs to be updated and recompiled if we have to change the look of the application. Too much non-reusable copy-paste Servlet can be viewed as "HTML inside Java"

Слайд 4





JSP (Java Server Page)
JSP is high-level abstraction of Java Servlets
JSP is a text document that contains two types of text: 
static data (HTML, SVG, WML, and XML)
JSP elements, which construct dynamic content
JSPs servlet is cached and re-used until the original JSP is modified
Описание слайда:
JSP (Java Server Page) JSP is high-level abstraction of Java Servlets JSP is a text document that contains two types of text: static data (HTML, SVG, WML, and XML) JSP elements, which construct dynamic content JSPs servlet is cached and re-used until the original JSP is modified

Слайд 5





JSP Example
<%@ page contentType="text/html; charset=UTF-8"%>
<html>
    <head>
        <title>First JSP</title>
    </head>
    <body>
        JSP Page
    </body>
</html>
Описание слайда:
JSP Example <%@ page contentType="text/html; charset=UTF-8"%> <html> <head> <title>First JSP</title> </head> <body> JSP Page </body> </html>

Слайд 6





JSP life cycle
Описание слайда:
JSP life cycle

Слайд 7





JSP vs Raw Servlet
Extension to Servlet (supplement each other)
Easier to maintain
Faster Development: no necessity to recompile and redeploy
Less code than Servlet
Описание слайда:
JSP vs Raw Servlet Extension to Servlet (supplement each other) Easier to maintain Faster Development: no necessity to recompile and redeploy Less code than Servlet

Слайд 8





Folders structure with direct access to jsp
Описание слайда:
Folders structure with direct access to jsp

Слайд 9





Folders structure without direct access to jsp
Описание слайда:
Folders structure without direct access to jsp

Слайд 10





JSP Example with Java inside HTML
 JSP Scriptlet is used to used to execute java source code in JSP
<% 
    int i=0;
%>  
  
 JSP Expression - evaluates a single Java expression and display its result.
Current Time: <%= java.util.Calendar.getInstance().getTime()  %> 
Описание слайда:
JSP Example with Java inside HTML JSP Scriptlet is used to used to execute java source code in JSP <% int i=0; %>      JSP Expression - evaluates a single Java expression and display its result. Current Time: <%= java.util.Calendar.getInstance().getTime()  %> 

Слайд 11





JSP Example with Java inside HTML
3. Declaration tag <%!  field or method declaration %>  
<%!
    int square(int a){ return a * a;}
%>  
Square : <%= square(10) %>



4. Directives tag <%@ JSP directives %>
    <%@ page contentType="text/html; charset=UTF-8"%>
    <%@ page import="java.util.*" %>
    <%@ include file="some-another-part.jsp" %>
Описание слайда:
JSP Example with Java inside HTML 3. Declaration tag <%!  field or method declaration %>   <%! int square(int a){ return a * a;} %>   Square : <%= square(10) %> 4. Directives tag <%@ JSP directives %> <%@ page contentType="text/html; charset=UTF-8"%> <%@ page import="java.util.*" %> <%@ include file="some-another-part.jsp" %>

Слайд 12





JSP Example with Java inside HTML (scriptlet)
<%@ page contentType="text/html; charset=UTF-8"%>
<html>
    <head>
        <title>First JSP</title>
    </head>
    <body>
        <%
            double num = Math.random();
            if (num > 0.5) {
        %>
            <h2>You'll be geek!</h2><p>(<%= num %>)</p>
        <%
            } else {
        %>
            <h2>Well, you won’t be geek ... </h2><p>(<%= num %>)</p>
        <%
            }
        %>
    </body>
</html>
Описание слайда:
JSP Example with Java inside HTML (scriptlet) <%@ page contentType="text/html; charset=UTF-8"%> <html> <head> <title>First JSP</title> </head> <body> <% double num = Math.random(); if (num > 0.5) { %> <h2>You'll be geek!</h2><p>(<%= num %>)</p> <% } else { %> <h2>Well, you won’t be geek ... </h2><p>(<%= num %>)</p> <% } %> </body> </html>

Слайд 13





MVC
Architecture of building applications is called MVC 
Model - classes of business logic and long-term storage
View - JSP pages
Controller - servlet.
Описание слайда:
MVC Architecture of building applications is called MVC Model - classes of business logic and long-term storage View - JSP pages Controller - servlet.

Слайд 14





Using JSP with Servlet
@WebServlet(name = "userPageServlet", urlPatterns = "/userpage")
public class UserServlet extends HttpServlet {
    @Override
    protected void doGet(
            HttpServletRequest req, HttpServletResponse resp
    ) throws ServletException, IOException {
        req.setAttribute("username", "Johny");
        req.getRequestDispatcher("/WEB-INF/pages/userIntro.jsp").forward(req, resp);
    }
}
Описание слайда:
Using JSP with Servlet @WebServlet(name = "userPageServlet", urlPatterns = "/userpage") public class UserServlet extends HttpServlet { @Override protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException { req.setAttribute("username", "Johny"); req.getRequestDispatcher("/WEB-INF/pages/userIntro.jsp").forward(req, resp); } }

Слайд 15





index.jsp vs custom.jsp
@WebServlet(name = "custom", urlPatterns = "/custom-page")
public class CustomServlet extends HttpServlet {
    @Override
    protected void doGet(
        HttpServletRequest req, HttpServletResponse resp
    ) throws ServletException, IOException {
        req.getRequestDispatcher("/pages/some-another.jsp").forward(req, resp);
    }
}
Описание слайда:
index.jsp vs custom.jsp @WebServlet(name = "custom", urlPatterns = "/custom-page") public class CustomServlet extends HttpServlet { @Override protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException { req.getRequestDispatcher("/pages/some-another.jsp").forward(req, resp); } }

Слайд 16





JSP expression language (EL)
${username} , ${user.name}
<p> Hello, ${author.name}</p>, <some:tag value=“${expr}”/>
Bean is searched by container in the next order:
page
request
session
application scopes
otherwise returns null
Описание слайда:
JSP expression language (EL) ${username} , ${user.name} <p> Hello, ${author.name}</p>, <some:tag value=“${expr}”/> Bean is searched by container in the next order: page request session application scopes otherwise returns null

Слайд 17





JSP Implicit Objects
Описание слайда:
JSP Implicit Objects

Слайд 18





Tag libraries
Advantages of using Tag Libs:
  - get rid of "scriptlets"
  - a simple HTML-like syntax
  - JSP code can be modified by HTML developers
  - code reuse
Описание слайда:
Tag libraries Advantages of using Tag Libs:   - get rid of "scriptlets"   - a simple HTML-like syntax   - JSP code can be modified by HTML developers   - code reuse

Слайд 19





JSP Tags syntax
<someTagLib:tag attr=“…”…> body </someTagLib:tag>

or if no body

<someTagLib:tag attr=“…” …/>
Описание слайда:
JSP Tags syntax <someTagLib:tag attr=“…”…> body </someTagLib:tag> or if no body <someTagLib:tag attr=“…” …/>

Слайд 20





JSP Tags types
1. Predefined (start with "jsp:")
<jsp:include page="hello.jsp"/>

2. External (custom tag libraries).
<c:set var="username" value="Johny" />
<c:out value="${username}" />
Описание слайда:
JSP Tags types 1. Predefined (start with "jsp:") <jsp:include page="hello.jsp"/> 2. External (custom tag libraries). <c:set var="username" value="Johny" /> <c:out value="${username}" />

Слайд 21





JSP Tag Example
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<h2>Hello,
    <c:choose>
        <c:when test="${not empty param.name}">
            <c:out value="${param.name}"/>
        </c:when>
        <c:otherwise>
            <c:out value="anonymous"/>
        </c:otherwise>
    </c:choose>
</h2>
<jsp:include page=“footer.jsp"/>
Описание слайда:
JSP Tag Example <%@ page contentType="text/html; charset=UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <h2>Hello, <c:choose> <c:when test="${not empty param.name}"> <c:out value="${param.name}"/> </c:when> <c:otherwise> <c:out value="anonymous"/> </c:otherwise> </c:choose> </h2> <jsp:include page=“footer.jsp"/>

Слайд 22





JSTL
	The standard JSP tag library (JSL) is an extension of the JSP specification that adds a JSP tag library for general purposes, such as parsing XML data, conditional processing, creating loops, and supporting internationalization.
Описание слайда:
JSTL The standard JSP tag library (JSL) is an extension of the JSP specification that adds a JSP tag library for general purposes, such as parsing XML data, conditional processing, creating loops, and supporting internationalization.

Слайд 23





JSTL Examples
Core Tags - basic tags, provide iteration, exception handling, url, forward and redirect response, etc.
Formatting and Localization Tags - formatting tags, provide opportunities for formatting Numbers, Dates and support for i18n localization and resource bundles.
SQL Tags - tags for working with SQL, support for working with databases like MySQL, Oracle, etc.
XML Tags - tags for working with XML documents. For example, for parsing XML, converting XML data, and executing XPath expressions.
JSTL Functions Tags - function-tags for processing strings, provides a set of functions that allow you to perform various operations with strings, etc. For example, by concatenating or splitting strings.
Описание слайда:
JSTL Examples Core Tags - basic tags, provide iteration, exception handling, url, forward and redirect response, etc. Formatting and Localization Tags - formatting tags, provide opportunities for formatting Numbers, Dates and support for i18n localization and resource bundles. SQL Tags - tags for working with SQL, support for working with databases like MySQL, Oracle, etc. XML Tags - tags for working with XML documents. For example, for parsing XML, converting XML data, and executing XPath expressions. JSTL Functions Tags - function-tags for processing strings, provides a set of functions that allow you to perform various operations with strings, etc. For example, by concatenating or splitting strings.

Слайд 24





JSTL core tags 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<c:out>
<c:remove>
<c:if>
<c:when>
<c:import>
<c:set>
<c:choose>
<c:otherwise>
<c:forEach>
<c:param>
Описание слайда:
JSTL core tags <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:out> <c:remove> <c:if> <c:when> <c:import> <c:set> <c:choose> <c:otherwise> <c:forEach> <c:param>

Слайд 25





JSTL formatting tags
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatNumber/>
<fmt:formatDate>
<fmt:setTimezone>
<fmt:requestEncoding>
<fmt:parseNumber>
<fmt:parseDate>
<fmt:setLocale>
<fmt:timeZone>
<fmt:message>
Описание слайда:
JSTL formatting tags <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <fmt:formatNumber/> <fmt:formatDate> <fmt:setTimezone> <fmt:requestEncoding> <fmt:parseNumber> <fmt:parseDate> <fmt:setLocale> <fmt:timeZone> <fmt:message>

Слайд 26





JSTL other tags
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>


${fn:contains()}
${fn:endsWith()}
${fn:indexOf()}
${fn:split()}
${fn:substring()}
${fn:toUpperCase()}
${fn:escapeXml()}
${fn:join()}
${fn:replace()}
${fn:startsWith()}
${fn:toLowerCase()}
${fn:trim()}
Описание слайда:
JSTL other tags <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> ${fn:contains()} ${fn:endsWith()} ${fn:indexOf()} ${fn:split()} ${fn:substring()} ${fn:toUpperCase()} ${fn:escapeXml()} ${fn:join()} ${fn:replace()} ${fn:startsWith()} ${fn:toLowerCase()} ${fn:trim()}

Слайд 27





Creating custom tag library
Extend classes TagSupport or BodyTagSupport (JSP Custom Tag Handler) group: 'javax.servlet.jsp', name: 'jsp-api', version: '2.0'
Write Tag Lib Definition file (my-tag-lib.tld)
Connect your tag library into JSP file and use it
Описание слайда:
Creating custom tag library Extend classes TagSupport or BodyTagSupport (JSP Custom Tag Handler) group: 'javax.servlet.jsp', name: 'jsp-api', version: '2.0' Write Tag Lib Definition file (my-tag-lib.tld) Connect your tag library into JSP file and use it

Слайд 28





Example: structure + servlet
@WebServlet(name = "homeServlet", urlPatterns = "/home")
public class HomeServlet extends HttpServlet {
    @Override
    protected void doGet(
        HttpServletRequest req, HttpServletResponse resp
    ) throws ServletException, IOException {
        req.setAttribute("users", Arrays.asList("Rikki", "Tommy", "Johny"));
        req.getRequestDispatcher("/WEB-INF/home.jsp").forward(req, resp);
    }
}
Описание слайда:
Example: structure + servlet @WebServlet(name = "homeServlet", urlPatterns = "/home") public class HomeServlet extends HttpServlet { @Override protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException { req.setAttribute("users", Arrays.asList("Rikki", "Tommy", "Johny")); req.getRequestDispatcher("/WEB-INF/home.jsp").forward(req, resp); } }

Слайд 29





Example: home.jsp
<%@ page contentType="text/html; charset=UTF-8" %>

<html>
    <head><title>Home</title></head>
    <body>
        <jsp:include page="fragments/calendar.jsp"/>
        <br><br>

        <jsp:include page="fragments/user-list.jsp"/>
    </body>
</html>
Описание слайда:
Example: home.jsp <%@ page contentType="text/html; charset=UTF-8" %> <html> <head><title>Home</title></head> <body> <jsp:include page="fragments/calendar.jsp"/> <br><br> <jsp:include page="fragments/user-list.jsp"/> </body> </html>

Слайд 30





Example: calendar.jsp
<%@ page import="java.util.Date" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:set var="date" value="<%=new Date()%>"/>
Today is <fmt:formatDate value="${date}" pattern="YYYY-MM-dd HH:mm:ss"/>
Описание слайда:
Example: calendar.jsp <%@ page import="java.util.Date" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="date" value="<%=new Date()%>"/> Today is <fmt:formatDate value="${date}" pattern="YYYY-MM-dd HH:mm:ss"/>

Слайд 31





Example: user-list.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:forEach var="user" items="${users}">
    <br>Username: <c:out value="${user}"/>
    <c:choose>
        <c:when test="${user == 'Tommy'}">
            need Jerry
        </c:when>
        <c:when test="${user == 'Rikki'}">
            need Tikki
        </c:when>
        <c:otherwise>
            need a gun
        </c:otherwise>
    </c:choose>
</c:forEach>
Описание слайда:
Example: user-list.jsp <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:forEach var="user" items="${users}"> <br>Username: <c:out value="${user}"/> <c:choose> <c:when test="${user == 'Tommy'}"> need Jerry </c:when> <c:when test="${user == 'Rikki'}"> need Tikki </c:when> <c:otherwise> need a gun </c:otherwise> </c:choose> </c:forEach>

Слайд 32





Literature
Java EE tutorial (3-9)
JSP Tutorial
Introduction to Java Server Pages
Описание слайда:
Literature Java EE tutorial (3-9) JSP Tutorial Introduction to Java Server Pages

Слайд 33





Homework Task 1
Implement a simple editing form on Servlet-JSP (JSTL) data stored in the session.
Implement output of data using Custom Taglib (keep "add" inside the JSP)
If any error happens – log and redirect user to custom error page
Add request blocking filter. Only user with Google Chrome 65 or later can access site – otherwise block requests and show error page. 
Add request logging filter. Log endpoints path and total execution time. Should measure all actions (even when request blocked)
Add request blocking filter. Deny all operations if time between 1AM-7AM. Microsoft Edge users should never come here and be stopped by user-agent filter.
Attributes lists should not be shared between two browsers
Описание слайда:
Homework Task 1 Implement a simple editing form on Servlet-JSP (JSTL) data stored in the session. Implement output of data using Custom Taglib (keep "add" inside the JSP) If any error happens – log and redirect user to custom error page Add request blocking filter. Only user with Google Chrome 65 or later can access site – otherwise block requests and show error page. Add request logging filter. Log endpoints path and total execution time. Should measure all actions (even when request blocked) Add request blocking filter. Deny all operations if time between 1AM-7AM. Microsoft Edge users should never come here and be stopped by user-agent filter. Attributes lists should not be shared between two browsers

Слайд 34





Homework 1
Описание слайда:
Homework 1



Теги Java Server Pages
Похожие презентации
Mypresentation.ru
Загрузить презентацию