Reputation: 520
I have to include my CGI script login.pl inside an HTML document index.html. I googled for answers and was surprised to find out that it was hard to get a definitive answer to this question. Some suggest using server side includes, but as far as I understand those are used for putting HTML inside of CGI, which is not what I want. I know that in JSP and PHP one can use tags like <% %> and php tags to include code inside of HTML document. Is there a similar construct for CGI? P.S. I am using CGI.pm framework and want to run output of login.pl inside of index.html.
Upvotes: 0
Views: 4881
Reputation: 1560
What you are looking for is HTML::Template or Template::Toolkit. Either of these will allow you to put tags in your HTML file and your CGI script can populate the data.
Note that you will be posting to or getting from the CGI script which will read the HTML file, populate it and then send built HTML file to the client. The client's browser would not be accessing the HTML file directly.
In your case, the client's browser will post to login.pl and then, on the server, the perl script will run and build the HTML file and serve it to the client.
Upvotes: 1
Reputation: 34003
It's not possible. CGI is a method for invoking scripts or programs on the server.
See https://en.wikipedia.org/wiki/Common_Gateway_Interface
PHP, ASP and JSP as special documents which are parsed by an interpreter on the server side which then executes the included code. HTML documents cannot be executed, thus, it's not possible.
However, you could make use of Server Side Includes (SSI, https://en.wikipedia.org/wiki/Server_Side_Includes) and include/call CGI programs from there - it's however, less powerful than PHP, JSP and ASP).
Upvotes: 0