Đang chuẩn bị liên kết để tải về tài liệu:
Java Server Pages: A Code-Intensive Premium Reference- P9

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Java Server Pages: A Code-Intensive Premium Reference- P9:Before you begin reading Pure JSP Java Server Pages, you might want to take a look at its basic structure. This should help you outline your reading plan if you choose not to read the text from cover to cover. This introduction gives you an overview of what each chapter covers. | title Welcome to JSP title head body out.println Welcome getUser request br From getCompany request body html You can see that the SubclassJSP provides empty jspinit and jspDestroy life-cycle methods which satisfy the JSP subclass requirements. It also makes calls to its parent s getUser and getCompany methods. Now compile the PureJSPBase servlet to the SERVER_ROOT purejsp WEB-INF classes directory and move the SubclassJSP.jsp to the SERVER_ROOT purejsp directory. You should then open your browser to http oca hosf 8080 purejsp SubclassJSP.jsp user Bob company Sams You should see a page similar to Figure 8.1. Figure 8.1 The output of SubclassJSP.jsp. Summary In this chapter you saw how you can subclass JSPs to provide common utility methods. You also looked at the requirements of both the superclass and the JSP subclass. In Chapter 9 we are going to cover using the JSP s implicit objects. Chapter 9 Using the JSP s Implicit Objects Overview As a JSP author you have access to certain objects that are available for use in JSP documents without being declared first. These objects are parsed by the JSP engine and inserted into the generated servlet as if you defined them yourself. - 81 - In reality the JSP engine recognizes the implicit object names and knows that they will be declared by or passed into the generated servlet. Here s a example of a code snippet containing a _jspService method public void _jspService HttpServletRequest request HttpServletResponse response throws lOException ServletException JspFactory _jspxFactory null PageContext pageContext null HttpSession session null ServletContext application null ServletConfig config null JspWriter out null Object page this String _value null try if _jspx_inited false _jspx_init _jspx_inited true _jspxFactory JspFactory.getDefaultFactory response.setContentType text html pageContext _jspxFactory.getPageContext this request response errorpage.jsp true 8192 true application pageContext.getServletContext config .