Danh mục tài liệu

XML, XSLT, Java, and JSP: A Case Study in Developing a Web Application- P6

Số trang: 50      Loại file: pdf      Dung lượng: 268.89 KB      Lượt xem: 13      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- P6: 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- P6232 Chapter 8 Java Servlet and Java Bean: BonForumEngine and BonForumStore Table 8.7 JSP Transitions vs. Actor-Chat Relationships Chat Exists Already Chat DoesNot Exist Actor Is Not Actor Is Actor Is in Chat Host Guest visitor guest host guest host executes starts chat executes chat(1) executes chat(1) executes chat(1)(2) chat visitor guest executes host guest forum joins chat chat executes chat(3) executes chat error Here are some notes for this table: n Numbered table items are optional, to be set by user preferences in a command, with alternatives as follows: 1. visitor starts chat 2. host executes chat, if multihosted chat allowed 3. guest executes chat n If the actor is a host or a guest, the actor is rejoining the chat. Rejoining Existing Chats As you can see, if a chat with the requested subject and topic combination does not exist, the visitor will become the host of a new chat for that combination. If the requested chat exists already, then what happens depends upon an option setting. One option is that the user will be taken back to “visitor starts chat” to try again with a dif- ferent subject, topic, or both. (Actually, in the release of bonForum for this book, this and other options listed in the notes are not yet available!) As seen in the table cells for the “visitor starts chat” row, the outcome when a requested chat already exists can be made to depend upon whether the visitor is already a host or a guest in that chat. If not, the visitor becomes a new guest in the chat. If the visitor already a member of the chat, the visitor rejoins as a host or a guest, whichever was the case before. (Again, in the book release of bonForum, the options within the table cells are the only options!) In a later release of bonForum, we will implement user preference settings using session attributes. Choices can be offered for the behavior of “visitor starts chat” when the requested chat already exists, as follows: 1. Always warn the user and request a new subject or new topic. 2. If the actor was in the chat, always join it with the previous status; otherwise, warn and ask again. 3. If the actor was in the chat, always join as a guest; otherwise, warn and ask again. 8.1 The BonForumEngine Servlet 233All these choices can be modified further according to whether the actor is restartingthe current chat. Until these preference settings are added, bonForum implements onlythe second choice. Looking at the table again, it is very easy to cause the various outcomes of thisdesired logic to happen.You simply need to set the bonForumCommand value to the cor-responding value in the table cell (or optional value, when that is implemented). Implementing the logic can also be quite simple.We leave the “visitor joins chat”part aside until Section 8.1.21, “The processRequest() Method: Handling ‘GuestExecutes Chat.’” Also leaving aside the numbered options (in the table notes), wecould suggest the following pseudocode: set bonForumCommand to host_executes_chat if chat exists if actor is not host in chat set bonForumCommand to guest_executes_chat endif endifHowever, the code that actually exists is not that simple. Are the subject and the topicokay? If not, the user is sent back to reinput them. If the subject and the topic areokay, the code determines whether they have already been taken by an existing chat. Ifthey are available, then a new chat will be started now. If they are taken, the code findsout even more. Is the visitor trying to restart the current chat for the session? (In thefuture, that information can be used for user messages or to control user preferences.)Is the actor already in the chat as a host or as a guest? If so, will the actor be joining orrejoining an existing chat? If so, the code must set some session attributes with theright values so that they reflect the chat. Some of the methods and variables used by this code might not become clea ...