XML, XSLT, Java, and JSP: A Case Study in Developing a Web Application- P8
Số trang: 50
Loại file: pdf
Dung lượng: 241.18 KB
Lượt xem: 14
Lượt tải: 0
Xem trước 5 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
XML, XSLT, Java, and JSP: A Case Study in Developing a Web Application- P8: Là một nhà phát triển Web, bạn biết những thách thức trong việc xây dựng các ứng dụng mạnh mẽ trên nhiều nền tảng. Tạo các ứng dụng di động trở nên thật sự có thể bằng cách sử dụng Java cho code và XML để tổ chức và quản lý dữ liệu. "XML, XSLT, Java, và JSP: Một trường hợp học" sẽ giúp bạn tối đa hóa khả năng của XML, XSLT, Java, và JSP trong các ứng dụng web của bạn....
Nội dung trích xuất từ tài liệu:
XML, XSLT, Java, and JSP: A Case Study in Developing a Web Application- P8332 Chapter 10 JSP Taglib: The bonForum Custom Tags The outputPathNames tag can be seen in use on the JSP page visitor_starts_chat_ frame.jsp, which presents the chat visitor with available chat subjects for a new chat. Here is the custom tag as it appears on the JSP: One of the strengths of custom tags is their reusability. It might seem strange, there- fore, that the outputPathNames tag is used only in one place in bonForum, to output node paths to chat subject elements from the XML database.The project is a proto- type, and so is the tag.The tag design attempts to include features that will make it useful in other situations when hierarchical information kept in XML needs to be transformed into sorted lists of node paths. We will start by showing the descriptor and the code for the tag.We’ll continue with brief discussions of its attributes and methods, and finally we’ll include some notes on its design. 10.4.1 The outputPathNames Descriptor The following listing shows the Tag element in the bonForum TLD that describes the outputPathNames custom action tag: outputPathNames de.tarent.forum.OutputPathNamesTag de.tarent.forum.BonForumTagExtraInfo JSP Outputs pathNames (node paths) from subTree of XML tree or forest. (Note: ignores chatItem nodes in bonForumXML.) docName true pathToSubTreeRootNode true 10.4 The OutputPathNamesTag Class 333 ancestorReplacer true nodeSeparator true Note that the only attribute that does anything in this book release of bonForum isdocName.10.4.2 The outputPathNames Tag HandlerThe following listing shows the source code for the OutputPathNamesTag class(stripped of its Javadoc comments, to save space): package de.tarent.forum; import java.util.*; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; /** Outputs pathNames from subTree of an XML tree * or forest ( except chatItems! ) */ public class OutputPathNamesTag extends BodyTagSupport { TreeMap outputTable = null; Iterator iterator = null; private static BonForumStore bonForumStore = null; private static BonLogger logOPNT = null; private static boolean loggingInitialized = false; private static String logging = null; private String docName = “”; private String pathToSubTreeRootNode = “”; private String ancestorReplacer = “”; private String nodeSeparator = “”; private void log( String where, String what ) { if( logging != null ) { logOPNT.logWrite( System.currentTimeMillis( ), pageContext.getSession( ➥).getId( ), where, what ); } } /** locates bonForumStore in application */334 Chapter 10 JSP Taglib: The bonForum Custom Tags private void findBonForumStore( ) { // code omitted here is in appendix, // and in Section 10.2.3, // “Finding Bean Methods from JSP Tags “ } /** Sets value of the docName attribute; * also initializes logging. */ public void setDocName( String value ) { if( !loggingInitialized ) { logging = pageContext.getServletContext( ).getInitParameter( “Logging” ➥); logOPNT = new BonLogger( “OutputPathNamesTagLog.txt”, logging ); ➥loggingInitialized = true; System.err.println( “OutputPathNamesTag init logging:” + logging ); ➥} if ( value.equals( null ) ) { value = “bonForumXML”; } docName = value; } /** Sets value of the pathToSubTreeRootNode attribute. */ public void setPathToSubTreeRootNode( String value ) { if( value.equals( null ) ) { value = “”; } pathToSubTreeRootNode = value; ...
Nội dung trích xuất từ tài liệu:
XML, XSLT, Java, and JSP: A Case Study in Developing a Web Application- P8332 Chapter 10 JSP Taglib: The bonForum Custom Tags The outputPathNames tag can be seen in use on the JSP page visitor_starts_chat_ frame.jsp, which presents the chat visitor with available chat subjects for a new chat. Here is the custom tag as it appears on the JSP: One of the strengths of custom tags is their reusability. It might seem strange, there- fore, that the outputPathNames tag is used only in one place in bonForum, to output node paths to chat subject elements from the XML database.The project is a proto- type, and so is the tag.The tag design attempts to include features that will make it useful in other situations when hierarchical information kept in XML needs to be transformed into sorted lists of node paths. We will start by showing the descriptor and the code for the tag.We’ll continue with brief discussions of its attributes and methods, and finally we’ll include some notes on its design. 10.4.1 The outputPathNames Descriptor The following listing shows the Tag element in the bonForum TLD that describes the outputPathNames custom action tag: outputPathNames de.tarent.forum.OutputPathNamesTag de.tarent.forum.BonForumTagExtraInfo JSP Outputs pathNames (node paths) from subTree of XML tree or forest. (Note: ignores chatItem nodes in bonForumXML.) docName true pathToSubTreeRootNode true 10.4 The OutputPathNamesTag Class 333 ancestorReplacer true nodeSeparator true Note that the only attribute that does anything in this book release of bonForum isdocName.10.4.2 The outputPathNames Tag HandlerThe following listing shows the source code for the OutputPathNamesTag class(stripped of its Javadoc comments, to save space): package de.tarent.forum; import java.util.*; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; /** Outputs pathNames from subTree of an XML tree * or forest ( except chatItems! ) */ public class OutputPathNamesTag extends BodyTagSupport { TreeMap outputTable = null; Iterator iterator = null; private static BonForumStore bonForumStore = null; private static BonLogger logOPNT = null; private static boolean loggingInitialized = false; private static String logging = null; private String docName = “”; private String pathToSubTreeRootNode = “”; private String ancestorReplacer = “”; private String nodeSeparator = “”; private void log( String where, String what ) { if( logging != null ) { logOPNT.logWrite( System.currentTimeMillis( ), pageContext.getSession( ➥).getId( ), where, what ); } } /** locates bonForumStore in application */334 Chapter 10 JSP Taglib: The bonForum Custom Tags private void findBonForumStore( ) { // code omitted here is in appendix, // and in Section 10.2.3, // “Finding Bean Methods from JSP Tags “ } /** Sets value of the docName attribute; * also initializes logging. */ public void setDocName( String value ) { if( !loggingInitialized ) { logging = pageContext.getServletContext( ).getInitParameter( “Logging” ➥); logOPNT = new BonLogger( “OutputPathNamesTagLog.txt”, logging ); ➥loggingInitialized = true; System.err.println( “OutputPathNamesTag init logging:” + logging ); ➥} if ( value.equals( null ) ) { value = “bonForumXML”; } docName = value; } /** Sets value of the pathToSubTreeRootNode attribute. */ public void setPathToSubTreeRootNode( String value ) { if( value.equals( null ) ) { value = “”; } pathToSubTreeRootNode = value; ...
Tìm kiếm theo từ khóa liên quan:
lập trình java phương pháp lập trình lập trình web ngôn ngữ php lập trình cơ bản XMLTài liệu có liên quan:
-
Giáo trình Lập trình logic trong prolog: Phần 1
114 trang 224 0 0 -
Giáo trình Lập trình C căn bản
135 trang 180 0 0 -
Luận văn tốt nghiệp Công nghệ thông tin: Xây dựng website bán hàng nông sản
67 trang 178 0 0 -
Giáo trình Lập trình C căn bản: Phần 1
64 trang 174 0 0 -
14 trang 141 0 0
-
161 trang 139 1 0
-
[Thảo luận] Học PHP như thế nào khi bạn chưa biết gì về lập trình?
5 trang 138 0 0 -
Tiểu luận môn Công nghệ phần mềm: Tìm hiểu công nghệ nhận diện giọng nói
27 trang 136 0 0 -
Giáo trình lập trình hướng đối tượng - Lê Thị Mỹ Hạnh ĐH Đà Nẵng
165 trang 128 0 0 -
Bài giảng Lập trình web nâng cao: Chương 8 - Trường ĐH Văn Hiến
36 trang 124 1 0