DT228/3 Web Development Active Server Pages & IIS Web server

Download DT228/3 Web Development Active Server Pages & IIS Web server

Post on 15-Jan-2016




5 download

Embed Size (px)


<ul><li><p>DT228/3 Web Development</p><p>Active Server Pages&amp; IIS Web server</p></li><li><p>Readability of ASP pages</p><p>Always always always ensure that code is:</p><p>INDENTED COMMENTED ID BLOCK</p><p>Indented - to reflect level of the code ajsdlkfjads etc 2) Well commented. Comments in ASP appear as the next subroutine will appear as followed by a function which will calculate.. Comments in HTML appear as HTML comments will be visible by view source in browser, ASP comments wont.</p></li><li><p>Readability of ASP pages3) Titled: At the top of each ASP page, should have an ID block explaining who write the script, date, script name, description and any revisions. Can use either ASP or HTML comments (depending on whether clients should be able to see the ID block) </p><p> etc</p></li><li><p>ASP SyntaxASP files for web output usually contain HTML tags. Any scripts intended for execution by the server must be between to distinguish them from HTML</p><p>The ASP engine looks specifically for code between - this code will then be parsed by the ASP engine. The remainder will be ignored</p></li><li><p>The default language for code is VBScript, although other languages can be used e.g. JavaScript, Jscript. </p><p>To set the language , use a language specification at the first line of the page using the @Language declarer:</p><p> etc etcYou dont have to set the language for VBSCript as its the default but its good practice to include it. </p><p>All examples here are in VBScript</p><p>ASP Scripting languages</p></li><li><p>ASP- simple example</p></li><li><p>ASP Declaring variables</p><p>To declare a variable use Dim e.g Dim Actors Variables are of type variant (You dont have to explicitly state string, integer etc.)</p><p>To declare an array add the array size on. e.g. Dim Actors(3) First element of the array has an index 0 e.g. Actors(0) = Tom Function Ubound determines the upper index of the array e.g. Ubount(Actors) has a value of 4 </p></li><li><p>ASP- Array example</p><p>. A list of the best actors in the film&gt; </p><p>etc</p><p>Do not have to include the Counter variableas in VB. </p></li><li><p>ASP Object ModelASP has seven built-in objects. Each of these objects has a set of properties , methods and collections that can be used to enhance ASP pages:</p><p>Request (Has a form collection to hold data entered into a form)Response (Has a write method to output to web page)SessionServerApplicationObjectContextASPError(new) Detailed info at : http://www.asp101.com/resources/aspobject.asp</p><p>Data structures where number of elements is variable (unlike arrays)</p></li><li><p>ASP Object Model - Request</p><p>Request - supplies information regarding the request the user sends to the Web application Request objects includes the following collections: Form (values from the form elements sent by the browser). Any elements in a HTML are available to to ASP using Request.Form (elementname) IF the post request method has been used QueryString values of the variables in a HTTP query string, which is data sent to the server in the URL I.e. www.blahblah.com?id=2347&amp;name=jim QueryString is populated if the get method is used</p></li><li>ASP Object Model Request HTML Form that collects 3 pieces of info .. header etc Your name: Your favourite colour: Your favourite film: </li><li>ASP Object Model Request output form content onto a web page</li><li><p>Use subroutines and functions in ASP pages in order to economise on code.. I.e to enable modules of code to be used and reused</p><p>Subroutines define a series of steps that accomplishes some task, but does not usually return a value</p><p>Functions accomplish a series of steps And usually return a single value </p><p>ASP: Subroutines and functions</p></li><li><p>ASP : Subroutines - example</p><p>The product of the two numbers entered is:</p><p> Result: </p><p> etc</p><p>Subroutine always starts with Sub, ends with End Subuse CallArguments passed to subroutine (num1, num2)</p></li><li><p>ASP : Function example etc</p><p> etc.. etc</p></li><li><p>ASP- reusable codeVery common in a web application to need to include common code such as headers/footers/navigation bars, subroutines etc across more than one Web page. </p><p>ASP allows the use of a Server Side Include directive called INCLUDE, which includes the contents of another file into the current file. Its the only SSI directive allowed in ASP (e.g. #echo, #exec etc are not allowed)</p><p>Must surround the include SSI directive as a HTML comment: Syntax:</p></li><li><p>ASP- reusable code - example</p><p>Will include the contents of header.html into the ASP page. It assumes header.html is in subdirectory include, relative to to the current directory. Note: good practice to place all include code into a single directory.. called include</p><p>Will include the contents of header.html into the ASP page. It assumes header.html is the files virtual path relative to the server root directory. Its not concernted with current directory. </p></li><li><p>Comparing ASP versus JSP Similarities</p><p>Both are scripting based technologies</p><p>Both enable dynamic web pages</p><p>Both help to separate the page design from the programming logic</p><p>Both provide an alternative to CGI Scripts, enabling easier and fast page development and deployment</p><p>Compilation: ASP was originally interpreted but ASP.net uses compiled code, similar to JSP</p></li><li><p>Using ASP versus JSP ?For a development project, how to choose whether ASP versus JSP may be used? (assuming PHP and others have been excluded!)</p><p>What technology is used already? ASP is usually used with Microsofts IIS, which requires Windows operating system - tied into Microsoft technology. Whereas JSP is platform independent - check whether the company is tied into any particular vendor products already that will guide decision&gt; ASP JSPWeb Server Microsoft IISAny web server, include apache, Netscape &amp; IIS</p><p>PlatformsMicrosoft WindowsMost popular platforms</p></li><li><p>Using ASP versus JSP ?Development skills - JSP support Javascript, Java code and tags (custom and JSLT). ASP supports both Vbscript and JavaScript. Need to check which skills are already available in the development team</p><p>Simplicity? ASP was traditionally regarded as simpler to develop (VBScript) than JSP (using Java code). However, the growth in use of re-usable tag based actions for JSP is changing this. If the company is open to using JSP tags, both are relatively simple. Re-usability across platform JSP will be portable across platforms, ASP generally is not.</p></li><li><p>Using ASP versus JSP ?Debugging/error resolution In JSP, the code is converted into Java servlets in the background any runtime errors refer to the servlet code which can make it difficult to find the error. ASP is not translated so any line references are within the ASP page itself. </p><p>Code re-use - Both allow common code to be taken out and re-used. JSP, with its use of custom and JSLT tags, is probably superior on this. Use of tags also enables easy global changes without individual page change. </p><p>Performance JSP traditionally considered faster as code is precompiled into servlets. However, now that ASP is part of ASP.Net which is also compiled comparable on performance.</p></li><li><p>Using ASP versus JSP ?</p><p>Open source JSP (and other java based technologies from Sun) are developed with input from the Java community. ASP is proprietary. Cost/quality/vendor support implications.</p></li></ul>