Server Side Scripting Norman White Where do we

  • Slides: 10
Download presentation
Server Side Scripting Norman White

Server Side Scripting Norman White

Where do we do processing? • Client side – Javascript (embed code in html)

Where do we do processing? • Client side – Javascript (embed code in html) – Java applets (send java program to run under the browser) • Server side – CGI program • Send form information to a program running on a server. • Server CGI program sends results back as HTML (or some other browser supported format) • Popular CGI languages are perl, python, java, C, C++, … – HTML with embedded code (Server side scripts) • Ph. P, ASP, Cold Fusion, JSP (Java Server Pages), javascript • In this case, the embedded code is executed as the web server sends the page out, not when the web browser goes to display the page.

Advantages of Server Side Scripting over CGI • No need to have CGI program

Advantages of Server Side Scripting over CGI • No need to have CGI program generate the HTML. • HTML automatically sent to the browser • Developer only needs to add code for server side processing like data base access etc. • Much less code to write, easier to debug, etc. • 3 Common environments, PHP, ASP, JSP – – PHP uses a C syntax ASP (Active Server Pages) is visual basic JSP (Java Server Pages) is Java syntax Can also do server side javascript

Embedded Scripts (Scriptlets) • Scripting statements are enclosed in script tags. – Ph. P

Embedded Scripts (Scriptlets) • Scripting statements are enclosed in script tags. – Ph. P <? php • statements … ? > <html> < body> < ? php $d=date("D"); if ($d=="Fri") echo "Have a nice weekend!"; ? > < /body> > < /html – ASP, JSP • <%statements …. . %> • ASP uses Visual Basic for Scripting,

ASP Example • Static Page

ASP Example • Static Page

Dynamic Page • Page is generated by ASP engine which executes scriptlet statements as

Dynamic Page • Page is generated by ASP engine which executes scriptlet statements as they are encountered.

Ph. P Examples <HTML> <HEAD> <TITLE> Hello World in PHP </TITLE> </HEAD> <BODY> <?

Ph. P Examples <HTML> <HEAD> <TITLE> Hello World in PHP </TITLE> </HEAD> <BODY> <? // Hello world in PHP print("Hello World"); ? > </BODY> </HTML>

How do we tell server that we have server side scripting? • Name the

How do we tell server that we have server side scripting? • Name the file. php, . asp, . jsp, . cfm • Note, the web server has to be configured to invoke the correct script interpreter. • Not all web servers support all scripting languages. – Microsoft supports ASP, can add Ph. P – Apache supports Php – Tomcat (a java based server) supports JSP.

Who does what where? • As a test of your understanding, how could you

Who does what where? • As a test of your understanding, how could you answer the following question. • Assuming the user and the web server are in the same time zone, and have synchronized time, how long (milliseconds) does it take to download a simple web page? • Could you create a web page that answers this question using PHP? • How hard is it? • What do you need to know?

Team question • In 5 minutes, sketch an answer to the previous question.

Team question • In 5 minutes, sketch an answer to the previous question.