Invoking java code with JSP scripting elements
好现在开始正式进入JSP的世界
What we need for JSP?
with**servlet**, it is easy to :
read from data
read HTTP request headers
set HTTP status codes and response headers
use cookies and session tracking
share data among servlets
remember data
get fun, high-paying job!!!
JSP makes it possible to:
use standard HTML tools such as DreamWeaver
Have different members of your team do the HTML layout than do the java programming
(队伍成员在布局的分工比在java代码的分工好)
Design Strategy: Limit Java Code in JSP Pages
提问:是把25行java代码卸载JSP页好还是25行写在java class里JSP用一行引用好?
为什么第二个好呢?
**Development**write in java environment
**Debugging**IDE helps you
**Testing**You can write a test routine with a loop that does 10,000 tests and reapply it after each change
**Reuse**You can use the same class from multiple pages.
JSP Expressions: <%= value %>
Format
<%= Java Expression %>
Controlling the Structure of Generated Servlets: The JSP page Directive
The import Attribute
<%@ page import="package.class" %>
<%@ page import="package.class1,...,package.classN" %>
The errorPage Attribute
<%@ page errorPage="Relative URL" %>
The isErrorPage Attribute
<%@ page isErrorPage="true" %>
<%@ page isErrorPage="false" %> <%-- Default --%>
Including Files inJSP Pages
Including Pages at Request Time: jsp:include
<jsp:include page="Relative address" />
jsp:include vs @
jsp:include whenever possible
include firective has additonal power
JSP Pages with XML Syntax
<?xml version="1.0" encoding="UTF-8" ?>
<your-root-element xmlns:jsp="http://java.sun.com/JSP/Page">
<your-tag1>foo</your-tag1>
<your-tag2>bar</your-tag2>
<your-root-element>