Danh mục

Java Server Pages: A Code-Intensive Premium Reference- P10

Số trang: 10      Loại file: pdf      Dung lượng: 249.41 KB      Lượt xem: 12      Lượt tải: 0    
Jamona

Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Java Server Pages: A Code-Intensive Premium Reference- P10:Before you begin reading Pure JSP Java Server Pages, you might want to take a look at its basicstructure. This should help you outline your reading plan if you choose not to read the text from cover tocover. This introduction gives you an overview of what each chapter covers.
Nội dung trích xuất từ tài liệu:
Java Server Pages: A Code-Intensive Premium Reference- P10Most often, you will not need to use the config object, because you will already have access to theServletContext through the implicit application object.pageThe page object is just as it sounds, a reference to the current instance of the JSP. It is initialized to theactual this reference by the generated servlet. The actual code snippet that does this follows:Object page = this;You use the page object just as you would a this object, to reference the current instance of yourgenerated servlet.exceptionThe implicit exception object only exists in a defined errorPage. It holds a reference to the uncaughtexception that caused the error page to be invoked. You can find a complete description of theerrorPage mechanism, including use of the implicit exception object in Chapter 6, Handling JSPErrors.SummaryIn this chapter, we covered the JSP implicit objects and how they are commonly used. We also talkedabout how they were created in the JSPs generated servlet. You should now have a clear understandingof the implicit objects that are available to you and what they represent.In Chapter 10, we cover using the JSPs standard actions.Chapter 10: Using JSP Standard ActionsOverviewThe JSP standard actions provide an abstraction that can be used to easily encapsulate common actions.You have already seen the standard actions specific to a JavaBean in Chapter 3, JavaBeans and JSPConcepts. The remaining standard actions are defined and used, where appropriate, in the followingsections.The action is used to provide tag/value pairs of information, by including them assubattributes of the , , and the actions. The syntax ofthe action is as follows:Table 10.1 contains the attributes and their descriptions for the action.Table 10.1: The Attributes for the ActionAttribute Definitionname This attribute represents the name of the parameter being referenced.value This attribute represents the value of the named parameter.The action provides a mechanism for including additional static and dynamic resourcesin the current JSP page. The syntax for this action is as follows:and - 91 - The first syntax description does a request-time inclusion, whereas the second contains a list of paramsubelements that are used to argue the request for the purpose of inclusion. Table 10.2 contains theattributes and their descriptions for the action.Table 10.2: The Attributes for the ActionAttribute Definitionpage This attribute represents the relative URL of the resource to be included.flush This attribute represents a mandatory Boolean value stating whether or not the buffer should be flushed. Currently, true is the only valid value for this attribute.To further explain how the works, we are gong to create two JSPs. The first, which willbe the included JSP, will act as the header of the second JSP document. This JSP will search therequest for an employees name and title. Listing 10.1 contains the source for our first JSP.Listing 10.1: header.jspOur second JSP will include the header.jsp in the top row of its table and pass it the employees nameand title, using the standard action. It will then include some static text indicating theemployees current statistics. Listing 10.2 contains the source code for our second JSP.Listing 10.2: EmployeeInfo.jsp Employee Information - 92 - Years of Employment: 7 Supervisor: Joe Salary: $93,000 - 93 - Email: bob@someemailaddress.com To see the in action, copy both of these JSPs to the /purejsp/directory and open your browser to the following URL:http://localhost:8080/purejsp/EmployeeInfo.jspYou will now see a page similar to Figure 10.1.Figure 10.1: The output from EmployeeInfo.jsp.To see how this really works, lets take a look at the generated servlets _jspService() method, whichis included in the following code snippet:public void _jspService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; - 94 -ServletContext application = null;ServletConfig config = null;JspWriter out = null;O ...

Tài liệu được xem nhiều: