Server-side scripting: Difference between revisions

Content deleted Content added
Tag: Reverted
Citation bot (talk | contribs)
Removed parameters. | Use this bot. Report bugs. | #UCB_CommandLine
 
(42 intermediate revisions by 36 users not shown)
Line 1:
{{Short description|Technique used in web development}}
{{See alsobroader|Dynamic web page#Server-side scripting}}
{{Multiple issues|
{{Expert needed|technology|reason=unfocused, scattered, unnecessary details|date=April 2012}}
Line 6:
}}
 
'''Server-side scripting''' is a technique used in [[web development]] which involves employing [[Scripting language|script]]sscripts on a web server which produces a response customized for each user's (client's) request to the website. The alternative is for the web server itself to deliver a [[static web page]]. Scripts can be written in any of a number of server-side scripting languages that are available (see below). Server-side scripting is distinguished from [[client-side scripting]] where embedded scripts, such as [[JavaScript]], are run client-side in a [[web browser]], but both techniques are often used together. The alternative to either or both types of scripting is for the web server itself to deliver a static web page.
[[File:Server-side websites programming languages.PNG|thumb|Languages used in server side scripting.]]
 
Server-side scripting is often used to provide a customized [[User interface chrome|interface for the user]]. These scripts may assemble client characteristics for use in customizing the response based on those characteristics, the user's requirements, access rights, etc. Server-side scripting also enables the website owner to hide the [[source code]] that generates the interface, whereas, with client-side scripting, the user has access to all the code received by the client. A downside to the use of server-side scripting is that the client needs to make further requests over the network to the server in order to show new information to the user via the [[web browser]].<ref>{{cite web |url=https://www.cloudflare.com/en-gb/learning/serverless/glossary/client-side-vs-server-side/ |title=What do client side and server side mean? Client side vs. server side |publisher=Cloudflare |access-date=17 April 2025 }}</ref> These requests can slow down the experience for the user, place more load on the server, and prevent the use of the application when the user is disconnected from the server.
'''Server-side scripting''' is a technique used in [[web development]] which involves employing [[Scripting language|script]]s on a web server which produces a response customized for each user's (client's) request to the website. The alternative is for the web server itself to deliver a [[static web page]]. Scripts can be written in any of a number of server-side scripting languages that are available (see below). Server-side scripting is distinguished from [[client-side scripting]] where embedded scripts, such as [[JavaScript]], are run client-side in a [[web browser]], but both techniques are often used together.
 
When the server serves data in a commonly used manner, for example, according to the [[Hypertext Transfer Protocol|HTTP]] or [[File Transfer Protocol|FTP]] [[Protocol (computing)|protocols]], users may have their choice of a number of client programs (most modern web browsers can request and receive data using both of those protocols). In the case of more specialized applications, programmers may write their own server, client, and communications protocol, that can only be used with one another.
Server-side scripting is often used to provide a customized interface for the user. These scripts may assemble client characteristics for use in customizing the response based on those characteristics, the user's requirements, access rights, etc. Server-side scripting also enables the website owner to hide the source code that generates the interface, whereas, with client-side scripting, the user has access to all the code received by the client. A downside to the use of server-side scripting is that the client needs to make further requests over the network to the server in order to show new information to the user via the web browser. These requests can slow down the experience for the user, place more load on the server, and prevent the use of the application when the user is disconnected from the server.
 
When the server serves data in a commonly used manner, for example, according to the [[Hypertext Transfer Protocol|HTTP]] or [[File Transfer Protocol|FTP]] [[Protocol (computing)|protocols]], users may have their choice of a number of client programs (most modern web browsers can request and receive data using both of those protocols). In the case of more specialized applications, programmers may write their own server, client, and communications protocol, that can only be used with one another.
 
Programs that run on a user's local computer without ever sending or receiving data over a network are not considered clients, and so the operations of such programs would not be considered client-side operations.
 
== History ==
[[Netscape]] introduced an implementation of [[JavaScript]] for server-side scripting with [[Netscape Enterprise Server]], first released in December, 1994 (soon after releasing JavaScript for browsers).<ref name = "Newscape JavaScript Guide-1998">{{cite web|title=Server-Side JavaScript Guide|publisher=Netscape Communications Corporation|year=1998|url=http://docs.oracle.com/cd/E19957-01/816-6411-10/getstart.htm|access-date=2012-04-25}}</ref><ref name = "Morgan-Netcape LiveWie">{{cite web|title=Using Netscape™ LiveWire™, Special Edition | author=Mike Morgan | url = http://vampire.rulez.org/onlinedoc/book/NetscapeLiveWire/ch6.htm | year = 1996 | publisher = Que }}</ref>
 
Server-side scripting was later used in early 19951996 by [[Fred DuFresne|Fred DuFrenseDufresne]] while developing the first website for Boston, MA television station [[WCVB-TV|WCVB]]. The technology is described in [http://patft.uspto.gov/netacgi/nph-Parser?Sect2=PTO1&Sect2=HITOFF&p=1&u=/netahtml/PTO/search-bool.html&r=1&f=G&l=50&d=PALL&RefSrch=yes&Query=PN/5835712 US patent 5835712]. The patent was issued in 1998 and is now owned by [[Open Invention Network]] (OIN). In 2010, OIN named Fred DuFresne a [https://web.archive.org/web/20111110192158/http://openinventionnetwork.com/press_release06_07_11.php "Distinguished Inventor"] for his work on server-side scripting.
 
== Explanation ==
In the earlier days of the web, server-side scripting was almost exclusively performed by using a combination of [[C (programming language)|C]] programs, [[Perl]] scripts, and [[shell script]]s using the [[Common Gateway Interface]] (CGI). Those scripts were executed by the [[operating system]], and the results were served back by the webserver[[web server]]. Many modern web servers can directly execute on-line [[scripting languageslanguage]]s such as [[Active Server Pages|ASP]], [[JavaServer Pages|JSP]], [[Perl]], [[PHP]] and [[Ruby (programming language)|Ruby]] either by the web server itself or via extension modules (e.g. [[mod_perl]] or [[mod_php]]) to the webserver. For example, [[WebDNA]] includes its own embedded database system. Either form of scripting (i.e., CGI or direct execution) can be used to build up complex multi-page sites, but direct execution usually results in less overhead because of the lower number of calls to external interpreters.
 
Dynamic websites sometimes use custom web application servers, such as [[GlassFish|Glassfish]], [[Plack (software)|Plack]] and [[Python (programming language)|Python]]'s "Base HTTP Server" library, although some may not consider this to be server-side scripting. When using dynamic web-based scripting techniques, developers must have a keen understanding of the logical, temporal, and physical separation between the client and the server. For a user's action to trigger the execution of server-side code, for example, a developer working with classic ASP must explicitly cause the user's browser to make a request back to the webserver.
Line 29 ⟶ 27:
 
== Server-side rendering ==
InWith the beginningadvent of the[[single-page webapplication]]s, contentan wasupdated generatedapproach purelyto onserver-side thescripting backwas endintroduced, known as server-side rendering. AfterWith server-side rendering, static HTML can be sent from the bigserver adoptionto ofthe frontclient, endand [[singleclient-side JavaScript then makes the web page application[[Dynamic web page|dynamic]]s, aby newattaching approachevent was introducedhandlers to generate the HTML usingelements thein clienta application,process butcalled on[[Hydration the(web back enddevelopment)|hydration]]. Examples of frameworks that usesupport [[Serverserver-side rendering|SSR]] are [[Next.js]], [[Nuxt.js]] and [[Nest.js]]. They use [[React.js]], [[Vue.js]], and [[Angular (web framework)|Angular]], respectively, to generate the content of the server.
 
== Server-side generation ==
Another similar to SSR technique of generating content for a website is using Server-side generation. This technique use application that create static html pages and then those files are send to the server. File generation can happen on completely different computer for example using [[continuous delivery]]. Example of SSG tools are [[Jekyll (software)|Jekyll]], [[Gatsby (software)|Gatsby]] or [[Eleventy (software)|Eleventy]]. Those sites are often hosted on [[Netlify]] or [[GitHub]] pages. GitHub also supports Jekyll projects where it automatically build the site when changes are added to [[git]].
 
== Languages ==
<!-- Please don't list languages like Python, Perl, and Ruby here, see [[Talk:Server-side_scripting#Too_many_languages]] -->
There are a number of server-side scripting languages available, including:
* [[ActiveVFP]] (*.avfp)
* [[Active Server Pages|ASP]] (*.asp)
* [[ASP.NET Web Forms]] (*.aspx)
* [[ASP.NET Web Pages]] (*.cshtml, *.vbhtml)
* [[ColdFusion Markup Language]] (*.cfm)
* [[Go (programming language)|Go]] (*.go)
* [[Google Apps Script]] (*.gs)
* [[Hack (programming language)|Hack]] (*.php)
* [[Haskell (programming language)|Haskell]] (*.hs) (example: [[Yesod (web framework)|Yesod]])
* [[Java (programming language)|Java]] (*.jsp, *.do) via [[JavaServer Pages]]
* [[JavaScript]] using [[Server-side JavaScript]] (*.ssjs, *.js) (example: [[Node.js]])
* [[Lasso (programming language)|Lasso]] (*.lasso)
* [[Lua (programming language)|Lua]] (*.lp *.op *.lua)
* [[Parser (programming language)|Parser]] (*.p)
* [[Perl]] via the [[CGI.pm]] module (*.cgi, *.ipl, *.pl)
* [[PHP]] (*.php, *.php3, *.php4, *.phtml)
* [[Python (programming language)|Python]] (*.py) (examples: [[Pyramid (web framework)#Pyramid|Pyramid]], [[Flask (web framework)|Flask]], [[Django (Web framework)|Django]])
* [[R (programming language)|R]] (*.rhtml)
* [[Ruby (programming language)|Ruby]] (*.rb, *.rbw) (example: [[Ruby on Rails]])
* [[Tcl (programming language)|Tcl]] (*.tcl)
* [[WebDNA]] (*.dna,*.tpl)
* [[OpenEdge Advanced Business Language|Progress WebSpeed]] (*.r,*.w)
 
An alternative to server-side rendering is [[Static site generator|static site generation]]. With server-side rendering, the page is generally assembled on the server once per each request. By contrast, with static site generation, the application generates all the static HTML pages at build time. These pre-built pages are then sent to the client at each request, without having to build them again. This leads to faster rendering times, since a new page doesn't have to be generated on every request; the server simply hands over a file it already generated in the past. The downside is that when some data on the page changes, it needs to be rebuilt. Examples of static site generation tools are [[Jekyll (software)|Jekyll]] and [[Gatsby (software)|Gatsby]]. Sites generated by static site generation tools are often hosted on [[Netlify]], [[Vercel]] or [[GitHub]] pages.
== See also ==
* [[Client-side scripting]]
Line 78 ⟶ 48:
== External links ==
{{Wikiversity | Server-Side Scripting}}
* {{curlie|Computers/Programming/Internet/Server_Side_Scripting}};
 
{{Web interfaces}}