lecture-6(moving towards script free jsp)
TRANSCRIPT
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
1/25
Lecture-6
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
2/25
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
3/25
Standard Actions JSTL (tag library) Actions
Custom Actions (next Lecture)
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
4/25
Makes a JavaBeans component available in a page
Gets a property value from a JavaBeans componentand adds it to the response
Set a JavaBeans property value
Includes the response from a servlet or JSP pageduring the request processing phase
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
5/25
Forwards the processing of a request to servlet or JSP page
Adds a parameter value to a request handed off to anotherservlet or JSP page using or
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
6/25
...
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
7/25
JSP is Easy
JSP is as easy as ...1 + 2 + 3 =
Built on custom tag infrastructure
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
8/25
Library features Recommended prefix
Core (control flow,
URLs, variable access)
c
Text formatting fmt
XML manipulation x
Database access sql
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
9/25
Iteration
var convention and variable access paging
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
10/25
Conditional evaluation
a equals b
Mutually exclusiveconditionals
a equals b
a equals cI dont know whataequals.
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
11/25
URL retrieval
Data exposed as String or Reader All core URLs supported (HTTP, FTP, HTTPS with JSSE)
Local, cross-context imports supported
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
12/25
Formatting and parsing
Numbers
Dates
Internationalization
Message bundles
Locale support
Message argument substitution
Hi {0}. I would like to {1} your money today. I will use it tobuy myself a big {2}.
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
13/25
Use of XSLT, XPath to access, display piecesof XML documents
Example later
http://www.cnn.com/cnn.rsshttp://www.cnn.com/cnn.rss -
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
14/25
Tags for Queries
Updates / inserts Transactions
DataSource-based connection management
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
15/25
Limitations of MVC , ,
clumsy scripting & expression elements to do morecomplicated Java things
With Expression Language ${expression}
Short and readable and fluid, like JavaScript
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
16/25
Simple & Concise Flexible (use in conjunction with tag libraries
& custom tags) Robust against Error
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
17/25
${1.2 + 2.3} => 3.5 ${3/0} => Infinity
\${1} => ${1} ${10 mod 4} => 2
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
18/25
${4.0 >= 3} => true ${4.0 ge 3} => true Not in Java
${100.0 == 100} => true ${(10*10) ne 100} => false Not in Java ${'hip' > 'hit'} => false Not in Java ${'a' < 'b'} => true Not in Java
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
19/25
${param.foo} => booyah ${param["foo"]} => booyah \${param["foo"]} => ${param["foo"]} ${header["host"]} => localhost:8080 ${header["accept"]} => */* ${header["user-agent"]} => Mozilla/5.0
(Macintosh; U; PPC Mac OS X; en-us)AppleWebKit/124 (KHTML, like Gecko) Safari/125
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
20/25
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
21/25
package coreservlets;
public class Salesbean {private double q1, q2, q3, q4;
public SalesBean(double q1Sales, double q2Sales, double q3Sales, doubleq4Sales) {...
}
public double getQ1() {return(q1);}
public double getQ2() {return(q2);}...
}}
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
22/25
package coreservlets;import java.io.*;import javax.servlet.*;import javax.servlet.http.*;
public class Conditionals extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
SalesBean apples = new SalesBean(150.25, -75.25, 22.25, -33.57);SalesBean oranges = new SalesBean(-220.25, -49.57, 138.25, 12.25);
request.setAttribute("apples", apples);
request.setattribute("oranges", oranges);RequestDispatcher dispatcher =request.getRequestDispatcher("/el/conditionals.jsp");
dispatcher.forward(request, response);}
}
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
23/25
package coreservlets;import java.io.*;import javax.servlet.*;import javax.servlet.http.*;
public class Conditionals extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
SalesBean apples = new SalesBean(150.25, -75.25, 22.25, -33.57);SalesBean oranges = new SalesBean(-220.25, -49.57, 138.25, 12.25);
request.setAttribute("apples", apples);
request.setattribute("oranges", oranges);RequestDispatcher dispatcher =request.getRequestDispatcher("/el/conditionals.jsp");
dispatcher.forward(request, response);}
}
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
24/25
...
...
-
8/3/2019 Lecture-6(Moving Towards Script Free JSP)
25/25