<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head profile="http://internetalchemy.org/2003/02/profile"> <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" /> <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" /> <meta name="dc.title" content="12. Web Application Development" /> <meta name="dc.subject" content="12. Web Application Development" /> <meta name="dc.creator" content="OpenLink Software Documentation Team ; " /> <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" /> <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" /> <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" /> <link rel="parent" href="webappdevelopment.html" title="Chapter Contents" /> <link rel="prev" href="rthjsp.html" title="Deploying JSP Applications" /> <link rel="next" href="pythonhosting.html" title="Python Hosting" /> <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" /> <link rel="stylesheet" type="text/css" href="doc.css" /> <link rel="stylesheet" type="text/css" href="/doc/translation.css" /> <title>12. Web Application Development</title> <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" /> <meta name="author" content="OpenLink Software Documentation Team ; " /> <meta name="copyright" content="OpenLink Software, 1999 - 2009" /> <meta name="keywords" content="" /> <meta name="GENERATOR" content="OpenLink XSLT Team" /> </head> <body> <div id="header"> <a name="perlhosting" /> <img src="../images/misc/logo.jpg" alt="" /> <h1>12. Web Application Development</h1> </div> <div id="navbartop"> <div> <a class="link" href="webappdevelopment.html">Chapter Contents</a> | <a class="link" href="rthjsp.html" title="Deploying JSP Applications">Prev</a> | <a class="link" href="pythonhosting.html" title="Python Hosting">Next</a> </div> </div> <div id="currenttoc"> <form method="post" action="/doc/adv_search.vspx"> <div class="search">Keyword Search: <br /> <input type="text" name="q" /> <input type="submit" name="go" value="Go" /> </div> </form> <div> <a href="http://www.openlinksw.com/">www.openlinksw.com</a> </div> <div> <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a> </div> <br /> <div> <a href="index.html">Book Home</a> </div> <br /> <div> <a href="contents.html">Contents</a> </div> <div> <a href="preface.html">Preface</a> </div> <br /> <div class="selected"> <a href="webappdevelopment.html">Web Application Development</a> </div> <br /> <div> <a href="webserver.html">The HTTP Server</a> </div> <div> <a href="wsacl.html">Web Services ACL (Access Control List)</a> </div> <div> <a href="vsp1.html">Virtuoso Server Pages (VSP)</a> </div> <div> <a href="vspx.html">Virtuoso Server Pages for XML (VSPX)</a> </div> <div> <a href="rthwritaspxapps.html">Deploying ASP.Net Web Applications</a> </div> <div> <a href="asmxhosting.html">ASMX Web Service Hosting</a> </div> <div> <a href="blogger.html">Blogging & Weblogs</a> </div> <div> <a href="servphpext.html">Deploying PHP Applications</a> </div> <div> <a href="rthjsp.html">Deploying JSP Applications</a> </div> <div class="selected"> <a href="perlhosting.html">Perl Hosting</a> </div> <div> <a href="pythonhosting.html">Python Hosting</a> </div> <div> <a href="rubyhosting.html">Ruby Hosting</a> </div> <br /> </div> <div id="text"> <a name="perlhosting" /> <h2>12.10. Perl Hosting</h2> <p>Virtuoso functionality can be enhanced through external libraries by loading shared objects or DLLs. The new functions are written in a language of the developer's choice and compiled to produce a shared library appropriate to the operating system. The path to the shared library must be declared in the Virtuoso INI file and the server restarted before it can be used.</p> <p>The Perl language is hosted within Virtuoso in this way. hosting_perl.so is the library used.</p> <p>The Virtuoso INI file uses a [Plugins] configuration section for listing shared libraries for the server to load upon startup. An example of this is:</p> <div> <pre class="programlisting"> [Plugins] LoadPath = /home/virtuoso/hosting Load1 = Hosting, hosting_perl.so .. </pre> </div> <p>The "Hosting" type defines the entry points for initialization of the runtime hosting environment, destruction of the user environment and execution of a file or string containing commands in the hosted language. It also returns a list of file extensions that it is capable of processing. Virtuoso dynamically defines memory-resident (no disk image) HTTP server handlers for each specified type. </p> <p>The Perl hosting plugin supports 'pl' extension. Hence, upon initialization of the hosting plugin, Virtuoso defines the <span class="computeroutput">__http_handler_pl(..)</span> function according to the API for file type handlers in the Virtuoso HTTP server. With this handler in place, each hit on a .pl file (file system or WebDAV) with appropriate execute permissions will cause the HTTP server to execute the code within it and return the result instead of simply the file's contents.</p> <p>The handler will call the __hosting_http_handler VSE with a special set of parameters to represent the HTTP environment correctly.</p> <p>Virtuoso will normally call the plugin to memory as required, and expel it when finished. This behavior can be controlled by the INI file parameter:</p> <div> <pre class="programlisting"> [HTTPServer] PersistentHostingModules = 1/0 default 0 </pre> </div> <p>Setting <span class="computeroutput">PersistentHostingModules</span> to "1" prevents Virtuoso from removing the interpreters from the HTTP threads after each request.</p> <div class="tip"> <div class="tiptitle">See Also:</div> <p> <a href="vseplugins.html">VSEI Plugins</a> </p> </div> <a name="ex_hostingsharedobjects" /> <div class="example"> <div class="exampletitle">Using the Perl Plugin</div> <p>Executing Perl code directly:</p> <div> <pre class="programlisting"> select __hosting_http_handler ('pl', 'print "hello world"; ', '', vector (), 'helloworld.pl'); </pre> </div> <div> <pre class="programlisting"> returns : hello world </pre> </div> <p>Executing a perl script file (perl/test_print.pl in the Virtuoso working directory):</p> <div> <pre class="programlisting"> /perl/test_print.pl ------------------- #!/usr/bin/perl print "hello world file"; </pre> </div> <div> <pre class="programlisting"> select __hosting_http_handler ('pl', 'perl/test_print.pl'); </pre> </div> <div> <pre class="programlisting"> returns : hello world file </pre> </div> </div> <div class="note"> <div class="notetitle">Note:</div> <p>The hosting_perl hosting module uses the perl <span class="computeroutput">tie()</span> function to "tie" up the STDIN, STDOUT, STDERR, exit() and %ENV perl objects. Untying any of these may lead to unpredictable results.</p> </div> <table border="0" width="90%" id="navbarbottom"> <tr> <td align="left" width="33%"> <a href="rthjsp.html" title="Deploying JSP Applications">Previous</a> <br />Deploying JSP Applications</td> <td align="center" width="34%"> <a href="webappdevelopment.html">Chapter Contents</a> </td> <td align="right" width="33%"> <a href="pythonhosting.html" title="Python Hosting">Next</a> <br />Python Hosting</td> </tr> </table> </div> <div id="footer"> <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div> <div id="validation"> <a href="http://validator.w3.org/check/referer"> <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /> </a> <a href="http://jigsaw.w3.org/css-validator/"> <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" /> </a> </div> </div> </body> </html>