Server-side:
Webapps

Parke Godfrey
1 October 2012
CSE-2041

Credits

These slides are based in part on ones from the following sources.

CGI (Common Gateway Interface)
Is the dynamic Web all CGI?


CGI as protocol — part of the HTTP protocol

Yes.


CGI as app (program) — called by the Web server

No.


We will focus on the “simple” case of CGI programs in LAMP.

Server-side Apps
Where to run?

Webapps
Components


Server-side

Need to capture the “input” from the client.

  • HTTP headers and parameters

  • Two methods to pass parameters:

    • GET
    • POST

Client-side

How to generate the “output” to go to the server?

Method GET

GET sends the parameters as part of the URL, URL encoded.

Some issues with GET are

  1. poor UI,

  2. exposed (no confidentiality),

  3. search engines do not index dynamic-looking URL’s, and

  4. limit on URL length.

A good point is that the URL — with the parameters in place — is bookmark-able.

Good for simple, “idempotent” applications.

Method POST

Parameters are passed as payload — in the request, from client to server.


For CGI programs / webapps:

Capturing Headers & Parameters
within a CGI program

Programming & Debugging Client-Server Apps
Can be quite painful!

CGI Program debugging techniques

Saving State
cookies — client browser stores them


Problems with cookies (from a webapp point of view)?

Cookie Syntax
in response

Set-Cookie: name=value;
expires=wd, d-m-y h:m:s TZ;
path=prefix of current URL;
domain=.xxx.xxx;
secure
Content-Type: mime

optional

Cookie Syntax
in request

Host: hostname;
Cookie: name=value; name=value; ... ;

Saving State
other ways?

Why not just use hidden fields in the “page” that the server delivers?

This is good for “intra-session”.

Cookies are good also for “inter-session”.

Other ways of saving state?