JSP là gì ? Java Server Pages
JavaServer™ Pages (JSP) is the Java™ Platform, Enterprise Edition (Java EE)
technology for building applications for generating dynamic web content, such as
HTML, DHTML, XHTML, and XML. JSP technology enables the easy authoring
of web pages that create dynamic content with maximum power and flexibility. (jsp2.1 spec)
JSP.1.1 What Is a JSP Page
A JSP page is a textual document that describes how to create a response object
from a request object for a given protocol. The processing of the JSP page may
involve creating and/or using other objects.
A JSP page defines a JSP page implementation class that implements the
semantics of the JSP page. This class implements the javax.servlet.Servlet
interface (see Chapter JSP.11, “JSP Container” for details). At request time a
request intended for the JSP page is delivered to the JSP page implementation
object for processing.
HTTP is the default protocol for requests and responses. Additional request/
response protocols may be supported by JSP containers. The default request and
response objects are of type HttpServletRequest and HttpServletResponse
respectively.
JSP.1.1
Một trang JSP là một “textual document” mô tả làm thế nào để tạo một đối tượng phản hồi từ một đối tượng yêu cầu cho một giao thức nhất định. Sự xử lý của trang JSP có thể bao gồm tạo và/hoặc sử dụng các đối tượng khác.
Một trang JSP định nghĩa một lớp thực thi trang JSP mà thực thi các ngữ nghĩa của trang JSP.
Lớp này bổ sung các giao diện javax.servlet.Servlet. Tại thời điểm yêu cầu một yêu cầu dành cho các trang JSP được chuyển về cho các đối tượng thực hiện trang JSP để xử lý.
HTTP là giao thức mặc định cho các yêu cầu và phản hồi. Các giao thức yêu cầu/phản hồi thêm vào có thể được hỗ trợ bởi JSP containers. Đối tượng yêu cầu/phản hồi mặc định là kiểu lần lượt tương ứng với HttpServletRequest và HttpServletResponse
//You can think of servlets as Java code with HTML inside; you can think of JSP as
HTML with Java code inside. (JSP-Overview p.3)
Mã nguồn trang JPS:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Order Confirmation</TITLE>
<LINK REL=STYLESHEET
HREF="JSP-Styles.css"
TYPE="text/css">
</HEAD>
<BODY>
<H2>Order Confirmation</H2>
Thanks for ordering <I><%= request.getParameter("title") %></I>!
</BODY></HTML>
http://localhost:8080/JPSoverview/test.jsp?title=Hello+JAVA+World
Khi chạy được kết quả
Order Confirmation
Thanks for ordering Hello JAVA World!
Request như thế nào, quá trình ra sao? Reponse nữa ??
http://my.opera.com/nguyenhung2709/blog/show.dml/493169
Không có nhận xét nào:
Đăng nhận xét