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--
How to talk about Java Servlets and CGI programs, I believe that many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
From the early days of the network, people wanted their network servers not only to display static documents, but also to extend the capabilities of the servers with the Universal Gateway Interface (CGI), but at the cost of additional processing. FastCGI integrates external CGI processing processes more closely with web servers, and for proprietary servers such as NSAPI and ISAPI API, they directly integrate external processes into the server as server plug-ins. Now with Java Servlets, they are powerful and can quickly replace your existing CGI programs.
What is Servlets?
Just as applet expands the capabilities of web browsers, Servlets, a Java component, expands the capabilities of web servers. For any kind of server-side processing, Servlets can be used as server-side includes or executed as a CGI program (which can be executed as a plug-in in JavaSoft's Java Web server). Servlets is portable, unlike CGI and proprietary API modules, you can use Java's "write once, run everywhere" mechanism to configure web applications in your enterprise. Servlets also runs smoothly. You create a database connection in Servlet, and the next time you visit Servlet, the connection still exists, unlike the CGI program. Servlets is also extensible, so you can use object-oriented programming methods to reduce development time. Servlets can run on any network server that supports Servlet. At present, Servlet SDK not only supports JavaSoft's Java Web server, but also supports Netscape, Apache and IIS, as well as a large number of third-party network servers.
Run your Servlet
Once the Servlet has been written and compiled, you can put it in the Servlet alias directory on the web server. Just like the cgi-bin alias directory on the server, any file placed in the Servlet directory, once requested as part of url, will be executed as Servlets. For example, BasicCGIServlet can be called with the following url: http://mycompany.com/Servlet/BasicCGIServlet. You can either call the url directly (and send Servlet a string requesting keyword / value pairs), or you can call it through an action in the HTML form. For more information about network servers that support Servlet, see the documentation information in JSDK.
Further usage
GenericServlet and HttpServlet provide a fixed base class for building Servlets. By overloading the service () method, you can build on them. For example, you can add support for response caching (see getLastModified () in HttpServlet), support for HTTP 1.1 methods, and so on. You can even build an extended template engine. Who really likes to build HTML code into their programs? )
Another use is to extend JSDK to support other types of form encoding in addition to the standard application/x-www-form-urlencoded mime type. For example, you can add support for multipart/form-data mime types to handle uploading files through HTTP. The interface methods getParameterNames (), getParameterValues (), and so on are all implemented in the sun.Servlet package, so you need to configure JSDK to add these support. As a workaround, you can implement the method yourself, but to do that, you need to copy the code or change the semantics of the JSDK. All of the above methods are feasible, but none of them are intact.
Now you should be able to create your own Java Servlets, which can be used to replace the traditional Perl and Cmax Cure + CGI programs. The object-oriented nature of Java and the "write once, run everywhere" mechanism make it easy to write Java Servlets. The robustness of Servlet can solve the problems related to state management, which are usually encountered when using only one-time CGI program to solve practical problems. Servlets can take advantage of all the features of the Java language, including JDBC and RMI. Since most web servers have added support for Servlet, Java will quickly become an optional language for developing enterprise applications.
After reading the above, have you mastered how to talk about Java Servlets and CGI programs? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.