In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 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 the JSP HTTP server supports CGI. 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.
JSP HTTP server supports CGI. In short, it supports client-side calls to server-side CGI routines. On the server side, CGI is generally stored in the form of executable files (for example, executable files, executable scripts). These CGI execution files can be run alone or accept requests from the client as parameters. On the other hand, the HTTP server is responsible for calling the CGI executable file and passing the request parameters of the client to the CGI program, and feedback the execution result of CGI to the client.
1. The call of the CGI program that the JSP HTTP server does not need parameters.
For CGI programs that do not need parameters, the function module has been fixed in the CGI program, and when called, the function module can be executed. This type of CGI program is generally used in situations where the function is relatively fixed. Here is the code that supports both CGI that requires parameters and CGI that does not need parameters:
/ / Parameter is null if (params.equals (") = = true) {command = fileName;} else / / Generate the command line {command = fileName +"+ params;} / / Execute CGI process as child process Process proc = m_rt.exec (command, null); / / Create CGI process output stream BufferedReader pin = new BufferedReader (new InputStreamReader (proc.getInputStream ())); String line = null / / Get the output from CGI process while ((line = pin.readLine ())! = null) {m_sout.println (line);} / Wait for CGI process finish proc.waitFor ()
In the above code, the CGI executable is called through the exec interface of the Runtime class of Java, and the execution output of CGI is returned to the client.
2. The call of the CGI program that the JSP HTTP server needs parameters
For CGI programs that require parameters, functional modules are not fixed, but parameters are required and passed in to perform the corresponding functions. This type of CGI program is relatively flexible. When called, the HTTP server must pass the parameter line of the client request into the CGI process, parse the request in the CGI program, and then execute the corresponding module. The HTTP server can communicate with the CGI process in three ways:
(1) pass in the execution parameters on the command line. See the above code ("command = fileName +"+ params;"). Pass in the executable file and parameters as the command line.
(2) write to the standard input (stdin) of the CGI process, the CGI program only needs to read the corresponding parameter lines from the standard input.
(3) write the parameter line to the environment variable QUERY_STRING of the CGI process. CGI reads command-line arguments from the environment variable QUERY_STRING.
This is the end of the article on "how the JSP HTTP server supports CGI". 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 out 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.