Wednesday, August 4, 2010

Server Pages

    Any programming language can generate web pages through CGI or an extension module or application server framework. This section lists technologies designed mainly or exclusively for server-side scripting, typically by embedding instructions directly in template web pages.

     

    ASP

    Microsoft designed solution allowing various languages (though generally VBscript is used) inside a HTML-like outer page. Primarily a Windows technology, but with limited support on other platforms.

     

    ASP.NET

    ASP.NET is a set of web application development technologies marketed by Microsoft. Programmers can use it to build dynamic web sites, web applications and XML web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology.

     

    COLDFIUSION

     

    Cross platform tag-based commercial server side scripting system.

     

    ESP

    ESP or Escapade was written in 1997 by Ed Carp, and enjoys wide use in Europe, but has had limited acceptance in the US.

    JSP

    A Java-based system for embedding Java-related code in HTML pages.

     

    LASSO

    A Datasource neutral interpreted programming language and cross platform server.

     

    PHP

    Common opensource solution based on including code in its own language into an HTML page.

    Server side java script

    A language generally used on the client side but also occasionally on the server side.

     

    S MX

    Lisp-like opensource language designed to be embedded into an HTML page.

     

    Server-side scripting is a web server technology in which a user's request is fulfilled by running a script directly on the web server to generate dynamic HTML pages. It is usually used to provide interactive web sites that interface to databases or other data stores. This is different from client-side scripting where scripts are run by the viewing web browser, usually in JavaScript. The primary advantage to server-side scripting is the ability to highly customize the response based on the user's requirements, access rights, or queries into data stores.

     

    Active Server Pages (ASP) is microsoft’s server-side script engine for dynamically-generated web pages. It is marketed as an add-on to Internet Information Services (IIS). Programming ASP websites is made easier by various built-in objects. Each object corresponds to a group of frequently-used functionality useful for creating dynamic web pages. In ASP 2.0 there are six such built-in objects: Application, ASPError, Request, Response, Server, and Session. Session, for example, is a cookie-based session object that maintains variables from page to page.

    Most ASP pages are written in VBScript, but any other Active Scripting engine can be selected instead by using the @Language directive or the <script language="language" runat="server"> syntax. Jscript (Microsoft's implementation of ECMAScript) is the other language that is usually available. PerlScript (a derivative of Perl) and others are available as third-party installable Active Scripting engines.

    InstantASP and ChiliASP are technologies that run ASP without Windows Operating System. There are large open source communities on the WWW, such as ASPNuke, which produce ASP scripts, components and applications to be used for free under certain license terms.

     

    Sample coding

    Several scripting languages may be used in ASP. However, the default scripting language (in classic ASP) is vb script

     

  1. <html>
  2. <body>
    1. <% Response.Write("Hello World!") %>
    2. </body>
    3. </html>

     

    JSP scripting elements

    There are three basic kinds of scripting elements that allow java code to be inserted directly into the servlet.

    • A declaration tag places a variable definition inside the body of the java servlet class. Static data members may be defined as well.

    <%! int serverInstanceVariable = 1; %>

    • A scriptlet tag places the contained statements inside the _jspService() method of the java servlet class.

    <% int localStackBasedVariable = 1;

    out.println(localStackBasedVariable); %>

    • An expression tag places an expression to be evaluated inside the java servlet class. Expressions should not be terminated with a semi-colon .

    <%= "expanded inline data " + 1 %>

     

    Examples of tags

     

    jsp:include

    <html>

    <head></head>

    <body>

    <jsp:include page="mycommon.jsp" >

    <jsp:param name="extraparam" value="myvalue" />

    </jsp:include>

    name:<%=request.getParameter("extraparam")%>

    </body></html>

    jsp:forward

    <jsp:forward page="subpage.jsp" >

    <jsp:param name="forwardedFrom" value="this.jsp" />

    </jsp:forward>

    jsp:plugin

    <jsp:plugin type=applet height="100%" width="100%"

    archive="myjarfile.jar,myotherjar.jar"

    codebase="/applets"

    code="com.foo.MyApplet" >

    <jsp:params>

    <jsp:param name="enableDebug" value="true" />

    </jsp:params>

    <jsp:fallback>

    Your browser does not support applets.

    </jsp:fallback>

    </jsp:plugin>

    jsp:useBean

    <jsp:useBean id="myBean" class="com.foo.MyBean" scope="request" />

    <jsp:getProperty name="myBean" property="lastChanged" />

    <jsp:setProperty name="myBean" property="lastChanged" value="<%= new Date()%>" />

     

     

    PHP is a reflective programming language originally designed for producing dynamic web pages PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

     

    PHP was written as a set of CGI binaries in the C programming language by the Danish/Greenlandic programmer Rasmus Lerdorf in 1994, to replace a small set of Perl scripts he had been using to maintain his personal homepage Lerdorf initially created PHP to display his résumé and to collect certain data, such as how much traffic his page was receiving. Personal Home Page Tools was publicly released on 8 June 1995 after Lerdorf combined it with his own Form Interpreter to create PHP/FI (this release is considered PHP version 2).

     

    Syntax

    PHP primarily acts as a filter. The PHP program takes input from a file or stream containing text and special PHP instructions and outputs another stream of data for display. From PHP 4, the PHP parser compiles input to produce bytecode for processing by the Zend Engine, giving improved performance over its interpreter predecessor. The Zend Engine II is at the heart of PHP

    The usual Hello World code example for PHP is:

     

    <?php

    echo 'Hello, World!';

    ?>

     

    ColdFusion is an application server and software development framework used for the development of computer software in general, and dynamic web sites in particular. In this regard, ColdFusion is a similar product to Microsoft ASP.NET or Java Enterprise Edition.

    The primary feature of ColdFusion is its associated scripting language, ColdFusion Markup Language (CFML), which compares to JSP, C#, or PHP and resembles HTML in syntax. "ColdFusion" is often used synonymously with "CFML", but it should be noted that there are additional CFML application servers besides ColdFusion, and that ColdFusion supports programming languages other than CFML, such as server-side Actionscript. Apart from the tag-based CFML syntax, ColdFusion supports embedded scripts that can be written in a JavaScript-like language, known as CFScript.

     

    Originally a product of Allaire, in 2001 the company was purchased by Macromedia, which was in turn acquired by Adobe System in 2005.

    ColdFusion is most often used for data-driven web sites or intranets. More advanced developers can use ColdFusion as a productivity layer above a J2EE platform or use ColdFusion as middleware in a service oriented architecture (SOA), generating SOAP or RESTful web services or Flash remoting.

    ColdFusion can also handle asynchronous events such as SMS and instant messaging via its gateway interface, available in ColdFusion MX 7 Enterprise Edition.

     

    An example:

    <cfform format="flash" method="post" width="400" height="400">

     <cfinput type="text" name="username" label="Username" required="yes" >

     <cfinput type="password" name="password" label="Password" required="yes" >

     <cfinput type="submit" name="submit" value="Sign In" >

    </cfform>

    ColdFusion also includes some XForms capability, and the ability to "skin" forms using XSLT.

     

    Example component with initialization method:

     

    <cfcomponent>

     <cffunction name="init" access="public" returntype="MyObject">

     <cfset this.something='do some object initialization'>

     <cfreturn THIS >

     </cffunction>

     

    Query of queries example

    <cfdirectory action="list" directory="/path/to/directory/" name="dirListing" />

     

    <cfquery name="xmlFiles" dbtype="query">

     SELECT *

    FROM dirListing

    WHERE name LIKE '%.xml'

    </cfquery>

     

    <cfquery name="imageFiles" dbtype="query">

     SELECT *

    FROM dirListing

    WHERE (name LIKE '%.jpg' OR name LIKE '%.gif' OR name LIKE '%.png')

    </cfquery>

     

    Lasso

    Lasso Professional combines an interpreted middleware programming language and server for developing internet applications which use web browsers for the client user interface to connect to HTTP and database servers. Lasso is developed by LassoSoft, LLC

     

    Lasso provides administration management over Lasso (via its internal users and groups) to control explicit access permissions-based to data sources and language features to improve security and data integrity in a multi-author web application development environment. Lasso Server provides access to MySQL and numerous other databases via JDBC and ODBC, as well as FileMaker Pro. Lasso Server runs on Mac OS X, Windows 2000, Windows 2003 and Red Hat Linux.

     

    Lasso's language, Lasso Dynamic Markup Language (LDML), can be written in a square bracket tag format which resembles HTML, or in a LassoScript format similar to many other scripting languages such as PHP, Perl, and Python. LDML can be written with procedural or object oriented techniques and structures, and supports numerous data types including arrays (indexed lists) and maps (name referenced lists).

     

    Lasso is an extendable language. It currently includes the ImageMagick suite of image manipulation tools, the ability to generate PDF documents and process and send email. Lasso also includes broad support for industry standards such as XML, SOAP, WSDL, JSON, Java E, and Java Beans. Developers can extend Lasso by writing their own custom routines which can be used and reused as custom tags or create new functionality via Java or the C programming language to suit their needs.

     

    Code Examples

     

    Hello World

    Here are three ways to say "Hello world!" on a Lasso page. The last one is of course the easiest.

     

    <?LassoScript 'Hello World!'; '<br>'; ?>

    ['Hello world!']<br>

    Hello world!<br>

     

    Square brackets are reserved in Lasso, so you have to use html entities, if you want to use square brackets on Lasso pages for other purposes than marking Lasso tags.

     

    Inlines

    [

    // this example begins with the LassoScript syntax

    // here we do a database search

     

    inline( -search, -database='db_name', -table='table_name',

    'field_name1'='searchvalue', -sortfield='field_name2');

     

     Records; // this marks beginning of a loop through found records

     Field('field_name2'); '<br>'; // here a db field was shown

     

     // next we build a web link using field values

     // many like to use the square bracket syntax for that kind

     // of thing, so we break the LassoScript

    ]

     

    <A HREF="mypage.html?e1=[Field('e1')]&e2=[Field('e2')]">Go for it!</A>

    <br>

    [

     // LassoScript syntax again; we only have to close the

    // so-called "container tags" (records, inline) that are still open

     

     /Records;

    /inline;

    ]

     


    Escapade

     

    Escapade, or ESP for short, is a server-side scripting language that is designed to provide an easy interface to database contents. It was written in 1997 by Ed Carp, and enjoys wide use in Europe, but has had limited acceptance in the US, due to limited exposure and the lack of an open source version of the software, but plans are underway to open source the software in early 2007.

     

    It is specifically designed to create dynamic web documents from this data. Escapade can be used to generate any kind of document - HTML, XML, text, and more.

     

    While server-side scripting is not a new concept, ESP is designed to enable programmers to have easy access to data in databases and display a formatted version of it in their web pages without having to resort to ASP or relatively complicated Perl or PHP scripts.

     

    Escapade was originally designed to fill the need for a simple server-side scripting product that ran on non-Windows platforms. As such, it currently runs in the UNIX and Linux environments, the "workhorse" platforms of the Internet and Intranet. Plans for Windows NT development are under consideration.

     

    In addition to current support for the popular and efficient MySQL database, plans are underway to support Oracle and other generic ODBC-compliant databases (Sybase, SQL Server, etc.) in the immediate future. Escapade is written in C, which makes it easy to port to other platforms.

     

    Server-side JavaScript

    Server-side JavaScript (SSJS) refers to JavaScript that runs on server-side. This term was coined because the language was originally limited to just client-side, i.e. client-side JavaScript (CSJS)..

    The first implementation of SSJS was Netscape's LiveWire, included in their Enterprise Server 2.0 product, released in 1996.

     

     

     

     


    SMX

    SMX is a macro processing language originally shipped with the Internet Factory's Commerce Builder software. This was a relatively popular web server in the early days of the internet, due to the ease with which a developer could produce an e-commerce website.

    Rather than re-implement websites in more popular languages, like Perl or PHP, a small group of SMX fans decided to re-implement the language itself as an Apache module.

    SMX was designed to embed macros in HTML/XML pages.

    A good example of a macro is %counter(). This embeds a simple incremental counter on an HTML page. To include the results of a SQL query on a page, you can simply type %sql(<dsn>,<query>,%col(1)<br />) in the middle of an XHTML page.

     

    Sample code

     

    Hello World

     

    Here is a Hello World code example:

     

    %expand%

    Hello World!

    Using variables to create output

    %expand%

    %set(name,World)

    Hello %name%!

     

     

    Forms Processing

    %expand%

    %if(%form(expr)

     ,<p>Result is: %expr(%form(expr))</p>

    )

    <form action="%client-url%" method=post>

    Simple math expression: <input name=expr>

    </form>

     

     

    Page counter

    %expand%

    %counter(hits) hits

     

    Database guestbook

    %expand%

    %if(%not(%exists(/tmp/gbook.sq3))

     ,%sql(sqlite:/tmp/gbook.sq3,create table guests (name text, comment text))

    )

    %if(%and(%form(name),%form(comment))

     ,%sql(sqlite:/tmp/gbook.sq3,"insert into guests (name, comment) values (%sqlq(%form(name)),%sqlq(%form(comment)))")

    )

    %sql(sqlite:/tmp/gbook.sq3,select * from guests

     ,<p>%html-quote(%col(name)) said %html-quote(%col(comment))<hr />

    )

    <p>

    <form action="%client-url%" method=post>

    <br />Name: <input name=name>

    <br />Comment: <input name=comment>

    <br /><input type=submit>

    </form>

No comments:

Post a Comment