In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to use Servlet and JavaServer Page. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Architecture Overview the following figure shows the proposed solution architecture. It involves a three-tier approach.
Solution architecture
Processing flow
The user fills out the HTML form. Send the form to Servlet. Servlet converts the HTTP request into an MQSeries message and places it in a queue. The back-end application processes the message and then sends back a reply through the message queue. Servlet retrieves the message from the queue and stores it in a Java Bean. The compiled Servlet and JavaServer Page are then called and the resulting HTML page is generated dynamically. JSP retrieves the message content of the page from Java Bean, merges it into HTML, and echoes the resulting page on the browser.
The solution leverages the following technologies:
HTML/HTTP, Java Beans, Servlet and JavaServer Page, Web server, message queue
The solution integrates the following products:
Netscape 4.0/Internet Explorer 3.0 or later, IBM HTTP Server 3.0, WebSphere 2.02, JDK version 1.1.7, MQSeries version 5.0
Connect to MQSeries
We chose the Servlet model because it has many advantages over CGI. Servlet is a standard server-side Java application that extends the functionality of the Web server. Servlet runs entirely on Web Server and doesn't download anything to the browser. The Servlet is loaded into the address space of the server during loading or during the initial request. After the initial request, Servlet responds very quickly. Servlet's init method prepares for Servlet to run. The init method is called only once per Servlet load. In the init method, establish a connection to the MQSeries queue manager as follows:
Public void init (ServletConfig config) throws ServletException {super.init (config); try {/ / Create a connection to the queue manager qMgr = new MQQueueManager ("NC.QManager");} catch (MQException ex) {System.out.println ("An MQ error occurred in init (): Completion code" + ex.completionCode + "Reason code" + ex.reasonCode); try {if (qMgr! = null) / / Disconnect from the queue manager qMgr.disconnect () } catch (MQException e) {System.out.println ("An MQ error occurred" + "in init () while disconnecting:" + "Completion code" + e.completionCode + "Reason code" + e.reasonCode);}
Since you only need to establish a connection to the queue manager of MQSeries once, and it takes a long time to establish a connection, the init method is an ideal place to perform this process. Subsequent calls to the Servlet are then executed faster. WebSphere also allows users to preload the Servlet by using the administrative GUI, so as the queue manager connection is established, the Servlet is ready to wait for any message to be delivered.
If MQException is captured in the init method, the above code disconnects from the queue manager. As a result, the user will have to reload the Servlet in order to establish a connection to the queue manager.
In order for Servlet to talk to MQSeries, you must use MQSeries Bindings for Java. MQSeries Bindings for Java enables you to write MQSeries applications in the Java language. These applications communicate directly with MQSeries queue managers to provide high-productivity, high-performance development options. They use Java native methods to call directly to the existing queue manager API instead of communicating through the MQSeries server connection channel; this provides better performance for Java MQSeries applications. We have to import the "com.ibm.mqbind.*" package in the code. The java class of MQSeries should also be in the classpath of WebSphere; this will allow the WebSphere application server to locate the MQSeries Bindings for Java package.
This is the end of the article on "how to use Servlet and JavaServer Page". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.