c:import, c:url, c:param, c:redirect.
2) importing by using c:import from jspf
url.jsp imp.jspf, c:url , redirect.jspx.
<!-- # 10: c:redirect, c:param: redirect.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
version="2.0">
<jsp:directive.page contentType=
"text/html; charset=Utf-8" />
<html><head><title> core</title></head>
<body>
<c:redirect url="urldestination.jspx">
<c:param name="fname" value="Ostap"/>
<c:param name="lname" value="Bender"/>
</c:redirect>
</body></html>
</jsp:root>
, urldestination.jspx.
<!-- # 11: ,
: urldestination.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
version="2.0">
<jsp:directive.page contentType=
"text/html; charset=Utf-8"/>
<html><head>
<title> c:url</title>
</head>
<body>
<jsp:text>
<br/>
, c:param:<br/>
</jsp:text>
<c:forEach var="ps" items="${param}">
<c:out value="${ps.key} - ${ps.value}"/><br/>
</c:forEach>
</body></html>
</jsp:root>
:
.
, c:param:
lname - Ostap
fname - Bender
JSTL fmt
.
<%@taglib uri=http://java.sun.com/jstl/fmt prefix=fmt%> JSP;
<jsp:root version=1.2 xmlns:fmt=
http://java.sun.com/jstl/fmt>...</jsp:root> JSP-.
:
<fmt:setLocale/> Locale, ;
<fmt:setBundle/>, <fmt:bundle/> ResourceBundle, . ResourceBundle, , ;
<fmt:message/> .
:
<fmt:timeZone/>, <fmt:setTimeZone/> , ;
<fmt:formatNumber/>, <fmt:formatDate/> / ( ) ;
|
|
<fmt:parseNumber/>, <fmt:parseDate/> / Number / Date.
fmt.
formatdatejsp.jspx
Locale.
<!-- # 12: : formatdate.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" version="2.0">
<jsp:directive.page contentType=
"text/html; charset=Utf-8"/>
<html><head><title> </title></head>
<body>
<jsp:useBean id="now" class="java.util.Date" />
<fmt:setLocale value="en-EN"/>
<jsp:text> English</jsp:text><br/>
: <fmt:formatDate value="${now}" /> <br/>
<fmt:setLocale value="ru-RU"/>
<jsp:text> Russian</jsp:text><br/>
: <fmt:formatDate value="${now}" /> <br/>
(-short): <fmt:formatDate value="${now}" type="time" timeStyle="short" /> <br/>
(-medium): <fmt:formatDate value="${now}" type="time" timeStyle="medium" /> <br/>
(-long): <fmt:formatDate value="${now}" type="time" timeStyle="long" /> <br/>
(-full): <fmt:formatDate value="${now}" type="time" timeStyle="full" /> <br/>
</body></html>
</jsp:root>
:
English
: Aug 14, 2007
Russian
: 14.08.2007
(-short): 23:23
(-medium): 23:23:02
(-long): 23:23:02 EEST
(-full): 23:23:02 EEST
<!-- # 13: : timezone.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
version="2.0">
<jsp:directive.page contentType=
"text/html; charset=Utf-8"/>
<html><head><title>timezone</title></head>
<body>
<jsp:useBean id="now" class="java.util.Date" />
<jsp:text>
<br/> fmt:formatDate
TimeZone
</jsp:text><br/>
< fmt:setLocale value="ru-RU"/>
<fmt:timeZone value="GMT+4:00">
<fmt:formatDate value="${now}" type="both"
dateStyle="full" timeStyle="full"/> <br/>
</fmt:timeZone>
</body></html>
</jsp:root>
:
fmt:formatDate TimeZone
15 2007 . 0:26:38 GMT+04:00
formatnumber.jspx
.
|
|
<!-- # 14: : formatnumber.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" version="2.0">
<jsp:directive.page contentType=
"text/html; charset=Utf-8"/>
<html><head><title>fomatnumber</title></head>
<body>
9876543.21: <br/>
<jsp:text> - </jsp:text>
<fmt:formatNumber value="9876543.21" /> <br/>
<jsp:text> - </jsp:text>
< fmt:formatNumber value="9876543.21" type="percent"/> <br/>
<fmt:setLocale value="ru-RU"/>
<jsp:text> - </jsp:text>
<fmt:formatNumber value="9876543.21" type="currency"/> <br/>
<fmt:setLocale value="en-EN"/>
<jsp:text> - </jsp:text>
<fmt:formatNumber value="9876543.21" type="currency"/> <br/>
<jsp:text> - </jsp:text>
<fmt:setLocale value="fr-FR"/>
<fmt:formatNumber value="9876543.21" type="currency"/> <br/>
</body></html>
</jsp:root>
:
9876543.21:
- 9 876 543,21
- 987 654 321%
- 9 876 543,21 .
- 9,876,543.21
- 9 876 543,21
JSTL sql
SQL JSP JSP.
<%@taglib uri=http://java.sun.com/jstl/sql prefix=sql%> JSP;
<jsp:root version=1.2 xmlns:sql=
http://java.sun.com/jstl/sql>...</jsp:root> JSP-.
:
<sql:dateParam> <sql:query> <sql:update>;
<sql:param> <sql:query> <sql:update>;
<sql:query> ;
<sql:setDataSource> data source <sql:query>, <sql:update>, <sql:transaction> ;
<sql:transaction> <sql:query> <sql:update> ;
<sql:update> - .
- JSP , MVC.
JSTL xml
XML JSP-.
<% @taglib uri=http://java.sun.com/jstl/xml prefix=x %> JSP-,
<jsp:root version=1.2 xmlns:x=
http://java.sun.com/jstl/xml>...</jsp:root> XML JSP.
:
<x:forEach> - XML- <c:choose>;
<x:choose> - XML- <c:forEach>;
<x:if> - XML- <c:if>;
<x:otherwise> - XML- <c:otherwise>;
<x:out> - XML- <c:out>;
<x:param> - XML- <c:param>, <x:transform>;
<x:parse> - XML-;
<x:set> - XML- <c:set>;
<x:transform> - XML-;
<x:when> - XML- <c:when>;
<x:choose> - XML- <c:choose>;
<x:forEach> - XML- <c:forEach>.
JSP- . include, , , .jspf, JSP. JSP- , , jsp:include. request, session applicatio n , . include, ( JSP ). JSP- jsp:include. , JSP- XML-. , XML JSP-.
|
|
<!-- #15: : incl_title.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
version="2.0">
<jsp:directive.page contentType=
"text/html; charset=Utf-8" />
<html><head>
<jsp:directive.include file="\WEB-INF\jspf\title.jspf" />
</head>
<body>
<h1>JSP-, include</h1>
<h3> include , .</h3>
</body></html>
</jsp:root>
<!-- # 16: : title.jspf -->
<title>Title from title.jspf</title>
. request session. . :
http://localhost:8082/home/thanks.jspx?lname=username. , .
<!-- # 17: include : thanks.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
<jsp:directive.page contentType="text/html;charset=Utf-8"/>
<html><head><title> include</title></head>
<body>
, jsp-<br/>
session <br/>
<jsp:include page="\WEB-INF\jspf\params.jsp"/>.
</body></html>
</jsp:root>
<!-- #18: : params.jsp -->
<jsp:directive.page contentType="text/html;charset=Utf-8"/>
ID -
<jsp:expression>session.getId()</jsp:expression>
:
, jsp-.
request, session
ID - 08C51EEC60A97E90C734101F54EA310E.
<c:import>. .
web-, , . :
- 404 Not Found. , ;
- 500 Internal Server Error. sendError(500) HttpServletResponse;
- . , web- , JSP.
|
|
JSP-, HTML-. error-page web.xml. :
<error-page>
<error-code>404</error-code>
<location>/error404</location>
</error-page>
<error-page>
<exception-type>java.io.IOException</exception-type>
<location>/errorIo</location>
</error-page>
error-code , exception-type .
, , ,
<jsp:directive.page errorPage="path" />, path -. , . java.lang.NullPointerException, error_hand.jsp
<!-- # 19: : gen_error.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
version="2.0">
<jsp:directive.page contentType=
"text/html; charset=Utf-8"/>
<jsp:directive.page errorPage="/error_hand.jspx" />
<html><head><title> </title></head>
<body>
<h2> !</h2>
<form>
<input type="submit" name="gen"
value=" "/>
</form>
<c:if test="${not emptyparam.gen}">
<jsp:declaration>String str;</jsp:declaration>
<jsp:scriptlet>str.length();</jsp:scriptlet>
</c:if>
</body></html>
</jsp:root>
, , , .
<!-- # 20: ERROR PAGE: error_hand.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
version="2.0">
<jsp:directive.page contentType=
"text/html; charset=Utf-8" />
<jsp:directive.page isErrorPage="true" />
<html><head><title> </title></head>
<body>
<p> ! <br/>
<jsp:expression>exception.toString()</jsp:expression>
</p></body></html>
</jsp:root>
JSLT EL , , JSP- param, java.util.Map.Entry, -.
params.jspx , form.jspx.
<!-- # 21: ,
param.jspx: form.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
version="2.0">
<jsp:directive.page contentType=
"text/html; charset=Utf-8" />
<html><head><title> </title></head>
<body>
<form action="params.jspx">
, , : <br/>
: <input type="text" name="fname" value="" /><br/>
: <input type="text" name="lname" value="" /><br/>
E-mail: <input type="text" name="e-mail" value="" /><br/>
<input type="submit" value="" /><br/>
</form>
</body></html>
</jsp:root>
. 19.1.
<!-- # 22: : params.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
version="2.0">
<jsp:directive.page contentType=
"text/html; charset=Utf-8" />
<html><head><title> </title></head>
<body>
JSTL EL<br/>
<c:forEach var="items" items="${param}">
|
|
<b><c:out value="${items.key}"></c:out></b>:
<c:out value="${items.value}"></c:out><br/>
</c:forEach>
<c:if test="${not empty param.fname}">
<b>:</b><c:out value="${param.fname}"/><br/>
</c:if>
<c:if test="${not empty param.lname}">
<b>:</b><c:out value="${param.lname}"/>
</c:if>
</body></html>
</jsp:root>
:
JSTL EL
lname:
fname:
e-mail: [email protected]
:
:
c:forEach , . , EL. ${param.lname} lname.
jsp:forward .
<!-- # 23: add_param
form.jspx: forward.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
version="2.0">
<jsp:directive.page contentType=
"text/html; charset=Utf-8" />
<html><head><title> </title></head>
<body>
<jsp:forward page="params.jspx">
<jsp:param name="addparam" value="added"/>
</jsp:forward>
</form>
</body></html>
</jsp:root>
, ( http://localhost:8082/FirstJSP/forward.jspx?name=UserName), , , param.jspx addparam added.
JSP
JSP, . JSP , , - - JSP . .. , . MVC (Model/View/Controller). Model - , View JSP, Controller .
, . :
. 19.2. JSP .
<!-- # 24: : index.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
<jsp:directive.page contentType="text/html; charset=Utf-8" />
<html><head><title>Index JSP</title></head>
<body>
<a href="controller">Main Controller</a>
</body></html>
</jsp:root>
login.jsp :
<!-- # 25: : login.jsp -->
<%@ page language="java" contentType="text/html;
charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<html><head><title>Login</title></head>
<body><h3>Login</h3>
<hr/>
< form name=" loginForm " method="POST"
action="controller" >
<input type=" hidden " name=" command " value=" login " />
Login:<br/>
<input type="text" name=" login " value=""><br/>
Password:<br/>
<input type="password" name=" password " value=""> <br/>
<input type="submit" value="Enter">
</ form ><hr/>
</body></html>
- Controller:
/* # 26: : Controller.java */
package by.bsu.famcs.jspservlet;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import by.bsu.famcs.jspservlet.commands.Command;
import by.bsu.famcs.jspservlet.manager.MessageManager;
import by.bsu.famcs.jspservlet.manager.ConfigurationManager;
public class Controller extends HttpServlet
implements javax.servlet.Servlet {
//,
RequestHelper requestHelper =
RequestHelper.getInstance();
public Controller() {
super ();
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{
processRequest(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{
processRequest(request, response);
}
private void processRequest(HttpServletRequest
request, HttpServletResponse response)
throws ServletException, IOException {
String page = null;
try {
// , JSP
Command command =
requestHelper.getCommand(request);
/* execute() Command
- */
page = command.execute(request, response);
//
} catch (ServletException e) {
e.printStackTrace();
//
request.setAttribute("errorMessage",
MessageManager.getInstance().getProperty(
MessageManager.SERVLET_EXCEPTION_ERROR_MESSAGE));
// JSP- c c
page = ConfigurationManager.getInstance()
.getProperty(ConfigurationManager.ERROR_PAGE_PATH);
} catch (IOException e) {
e.printStackTrace();
request.setAttribute("errorMessage",
MessageManager.getInstance()
.getProperty(MessageManager.IO_EXCEPTION_ERROR_MESSAGE));
page = ConfigurationManager.getInstance().getProperty(ConfigurationManager.ERROR_PAGE_PATH);
}
//
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher(page);
dispatcher.forward(request, response);
}
}
/* # 27: : RequestHelper.java */
package by.bsu.famcs.jspservlet;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import by.bsu.famcs.jspservlet.commands.Command;
import by.bsu.famcs.jspservlet.commands.LoginCommand;
import by.bsu.famcs.jspservlet.commands.NoCommand;
public class RequestHelper {
private static RequestHelper instance = null;
HashMap<String, Command> commands =
new HashMap<String, Command>();
private RequestHelper() {
//
commands.put("login", new LoginCommand());
}
public Command getCommand(HttpServletRequest request) {
//
String action = request.getParameter("command");
// ,
Command command = commands.get(action);
if (command == null) {
//
command = new NoCommand();
}
return command;
}
// Singleton
public static RequestHelper getInstance() {
if (instance == null) {
instance = new RequestHelper();
}
return instance;
}
}
/* # 28: , : Command.java: LoginCommand.java: NoCommand.java */
package by.bsu.famcs.jspservlet.commands;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
public interface Command {
public String execute(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException;
}
package by.bsu.famcs.jspservlet.commands;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import by.bsu.famcs.jspservlet.logic.LoginLogic;
import by.bsu.famcs.jspservlet.manager.ConfigurationManager;
import by.bsu.famcs.jspservlet.manager.MessageManager;
public class LoginCommand implements Command {
private static final String PARAM_NAME_LOGIN = "login";
private static final String PARAM_NAME_PASSWORD
= "password";
public String execute(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String page = null;
//
String login = request.getParameter(PARAM_NAME_LOGIN);
String pass = request.getParameter(PARAM_NAME_PASSWORD);
//
if (LoginLogic.checkLogin(login, pass)) {
request.setAttribute("user", login);
// main.jsp
page = ConfigurationManager.getInstance()
.getProperty(ConfigurationManager.MAIN_PAGE_PATH);
} else {
request.setAttribute("errorMessage",
MessageManager.getInstance()
.getProperty(MessageManager.LOGIN_ERROR_MESSAGE));
page = ConfigurationManager.getInstance()
.getProperty(ConfigurationManager.ERROR_PAGE_PATH);
}
return page;
}
}
package by.bsu.famcs.jspservlet.commands;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import by.bsu.famcs.jspservlet.manager.ConfigurationManager;
public class NoCommand implements Command {
public String execute(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
/* */
String page = ConfigurationManager.getInstance()
.getProperty(ConfigurationManager.LOGIN_PAGE_PATH);
return page;
}
}
/* # 29: , properties-
:
ConfigurationManager.java: MessageManager.java */
package by.bsu.famcs.jspservlet.manager;
import java.util.ResourceBundle;
public class ConfigurationManager {
private static ConfigurationManager instance;
private ResourceBundle resourceBundle;
// config.properties
private static final String BUNDLE_NAME = "config";
public static final String DATABASE_DRIVER_NAME =
"DATABASE_DRIVER_NAME";
public static final String DATABASE_URL =
"DATABASE_URL";
public static final String ERROR_PAGE_PATH =
"ERROR_PAGE_PATH";
public static final String LOGIN_PAGE_PATH =
"LOGIN_PAGE_PATH";
public static final String MAIN_PAGE_PATH =
"MAIN_PAGE_PATH";
public static ConfigurationManager getInstance() {
if (instance == null) {
instance = new ConfigurationManager();
instance.resourceBundle =
ResourceBundle.getBundle(BUNDLE_NAME);
}
return instance;
}
public String getProperty(String key) {
return (String)resourceBundle.getObject(key);
}
}
package by.bsu.famcs.jspservlet.manager;
import java.util.ResourceBundle;
public class MessageManager {
private static MessageManager instance;
private ResourceBundle resourceBundle;
// messages. properties
private static final String BUNDLE_NAME = "messages";
public static final String LOGIN_ERROR_MESSAGE = "LOGIN_ERROR_MESSAGE";
public static final String SERVLET_EXCEPTION_ERROR_MESSAGE =
"SERVLET_EXCEPTION_ERROR_MESSAGE";
public static final String IO_EXCEPTION_ERROR_MESSAGE = "IO_EXCEPTION_ERROR_MESSAGE";
public static MessageManager getInstance() {
if (instance == null) {
instance = new MessageManager();
instance.resourceBundle =
ResourceBundle.getBundle(BUNDLE_NAME);
}
return instance;
}
public String getProperty(String key) {
return (String)resourceBundle.getObject(key);
}
}
config.properties:
###############################
## Application configuration ##
###############################
DATABASE_DRIVER_NAME=com.mysql.jdbc.Driver
DATABASE_URL=jdbc:mysql://localhost:3306/db1?user=
root&password=root
ERROR_PAGE_PATH=/jsp/error.jspx
LOGIN_PAGE_PATH=/jsp/login.jspx
MAIN_PAGE_PATH=/jsp/main.jspx
messages.properties:
###############################
## Messages ##
###############################
LOGIN_ERROR_MESSAGE=Incorrect login or password
SERVLET_EXCEPTION_ERROR_MESSAGE=ServletException: Servlet encounters difficulty
IO_EXCEPTION_ERROR_MESSAGE=IOException: input or output error while handling the request
- LoginLogic, :
/* # 30: - : LoginLogic.java */
package by.bsu.famcs.jspservlet.logic;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.DriverManager;
import by.bsu.famcs.jspservlet.manager.ConfigurationManager;
public class LoginLogic {
public static boolean checkLogin(
String login, String password) {
//
try {
//
String driver = ConfigurationManager.getInstance().getProperty(ConfigurationManager.DATABASE_DRIVER_NAME);
Class.forName(driver);
Connection cn = null;
try {
String url = ConfigurationManager.getInstance()
.getProperty(ConfigurationManager.DATABASE_URL);
cn = DriverManager.getConnection(url);
PreparedStatement st = null;
try {
st = cn.prepareStatement(
"SELECT * FROM USERS WHERE LOGIN =? AND PASSWORD =?");
st.setString(1, login);
st.setString(2, password);
ResultSet rs = null;
try {
rs = st.executeQuery();
/* ,
*/
return rs.next();
} finally {
if (rs!= null)
rs.close();
}
} finally {
if (st!= null)
st.close();
}
} finally {
if (cn!= null)
cn.close();
}
} catch (SQLException e) {
e.printStackTrace();
return false;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return false;
}
}
}
main.jsp :
<!-- # 31: : main.jsp -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c=http://java.sun.com/jsp/jstl/core
version="2.0">
<jsp:directive.page contentType="text/html;
charset=Utf-8" />
<html><head><title>Welcome</title></head>
<body><h3>Welcome</h3>
<hr />
<c:out value="${ user }, Hello!"/>
<hr />
<a href="controller">Return to login page</a>
</body></html>
</jsp:root>
error.jsp (, ):
<!-- # 32: , : error.jspx -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c=
"http://java.sun.com/jsp/jstl/core" version="2.0">
<jsp:directive.page contentType=
"text/html; charset=Utf-8" />
<html><head><title>Error</title></head>
<body>
<h3>Error</h3>
<hr />
<jsp:expression>
(request.getAttribute("errorMessage")!= null)
? (String) request.getAttribute("errorMessage")
: "unknown error"</jsp:expression>
<hr />
<a href="controller">Return to login page</a>
</body></html>
</jsp:root>
, , web.xml, - controller, .. mapping.
<!-- # 33: : web.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" >
<display-name>Project</display-name>
<servlet>
<description>
</description>
<display-name>
Controller</display-name>
<servlet-name>Controller</servlet-name>
<servlet-class>
by.bsu.famcs.jspservlet.Controller</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Controller</servlet-name>
<url-pattern>/controller</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
<servlet-name>
controller, <url-pattern> /controller.
Web- Tomcat 5.5.*, :
http://localhost:8082/Project/index.jspx
:
http://localhost:8082/Project/controller
19
, JSP . .
d) . : , , , . . JSP c .
e) . : , , , , , . ID, . ID. JSP. .
f) . , , . . JSP.
g) . . . .
h) . . JSP. . .
i) . , . . , . .
j) . . . .
B
4 , JSP , .
19
19.1.
j int JSP?
1) <%! int j = 1 %>;
2) <%@ int j = 2 %>;
3) <%! int j = 3; %>;
4) <%= int j = 4 %>;
5) <%= int j = 5; %>.
19.2.
JSP ?
1) error;
2) page;
3) this;
4) exception;
5) context.
19.3.
_jspService()?
1) javax.servlet.jsp.Jsp;
2) javax.servlet.jsp.JspServlet;
3) javax.servlet.jsp.JspPage;
4) javax.servlet.jsp.HttpJspPage;
5) javax.servlet.jsp.HttpJspServlet.
19.4.
jsp:useBean
<jsp:useBean id="appJsp"
class="main.ApplicationJSP"
scope="application" />
?
1) ServletConfig;
2) HttpApplication;
3) ServletContext;
4) ServletConfig;
5) ApplicationContext.
19.5.
JSP JavaBean ?
1) jsp:useBean.toString;
2) jsp:param.property;
3) jsp:propertyType;
4) jsp:getProperty;
5) jsp:propertyToString;
JDBC
,
JDBC (Java DataBase Connectivity) (API) Java . JDBC, . JDBC :
1. , , ODBC ( JDBC-ODBC ). sun.jdbc.odbc.JdbcOdbcDriver JDK.
2. , (native) (.. ).
3. , Java-, , , .
4. , native-.
, , , . , , . , , , .. , JDBC, ODBC.
. 20.1. JDBC-ODBC-
JDBC , . JDBC SQL- (), , .
, JDBC J2EE, Web-, .