[Gambas-user] Gambas server pages

François garulfounix at ...626...
Mon Sep 22 18:59:49 CEST 2008


Le Monday 22 September 2008 15:06:05 Benoit Minisini, vous avez écrit :
> Hi,
>
> In the last revision of the 2.0 branch, you will find some sort of gambas
> scripter hack that allows you to write ASP-like files that I named "Gambas
> server pages".
>
> Put that in a text file, make it executable, and run it. Do not forget to
> run "make install" in the app source directory to recompile and install the
> new scripter.
>
> --8<--------------------------------------------------------------------
> #!/usr/bin/env gbw2
> <%
> DIM sEnv AS String
> %>
>
> <!-- Variable declaration must come before any HTML -->
>
> <html>
>
> <h2>CGI script environmental variables</h2>
>
> <table border="1" cellspacing="0" cellpadding="2">
>
>   <tr>
>     <th align="left">Name</th>
>     <th align="left">Value</th>
>   </tr>
>
> <% FOR EACH sEnv IN Application.Env %>
>   <tr valign="top">
>     <td><%= sEnv %></td>
>     <td><%= Application.Env[sEnv] %> </td>
>   </tr>
> <% NEXT %>
>
> </table>
>
> </html>
> --8<--------------------------------------------------------------------
>
> As you can see, the server page is a script, but the script executable
> is 'gbw2', not 'gbs2'.
>
> 'gbw2' is actually a symbolic link to 'gbs2'. When 'gbs2' detects than it
> is run from the 'gbw2' symbolic link, it knows that it will have to process
> a server page and not a script. Then 'gbs2' will transform the server page
> into...a normal script, and will execute it.
>
> Except the initial line with the '#!/usr/bin/env gbw2' magic, the syntax is
> very similar to ASP pages.
>
> * <% XXX %> introduces any Gambas code.
>
> * <%= XXX %> evaluates a Gambas expression, translates it into HTML, and
> inserts the HTML inline.
>
> Note that the gb.web component is used by default. So you can use the
> Session object, the Response object, the Request object, and so on.
>
> These Gambas server page are CGI scripts, and must be managed as any other
> CGI script in your preferred web server.
>
> I hope I gave enough information so that you can test that quick & dirty
> hack. :-)
>
> Regards,

Ho that's very excellent Benoit ! :)  Thank you.
This is another way to have dynamic pages by using GSP instead of PHP ! Really  
nice.

I'm testing this immediatly. (I hope my problem is resolved about the install 
issue in order to try.)

-- 
GarulfoUnix - François Gallo 
(fr)Contributeur à Gambas(Traductions, documentations, rapport de bugs...)
(en)Gambas contributor(Translation, documentation, bugs report...and so on)




More information about the User mailing list