- Asked 3/4
- 2076 Chaitra · 5 marks
- 2074 Asoj · 7 marks
- 2074 Chaitra · 4 marks
Client-side versus server-side scripting
Short answer
Client-side scripting runs in the browser using JavaScript for validation and UI updates, while server-side scripting runs on the server using PHP or Java for database work and authentication. Server-side code is hidden and more secure but needs a round trip.
What is the difference between client-side scripting and server-side scripting? Explain with example.
Client-side scripting means scripts that are downloaded with the page and run in the user's browser (e.g. JavaScript). Server-side scripting means scripts that run on the web server, which generates the HTML sent to the browser (e.g. PHP, JSP/Servlets, ASP.NET, Node.js).
| Basis | Client-side scripting | Server-side scripting |
|---|---|---|
| Execution | In the browser | On the web server |
| Languages | JavaScript, VBScript | PHP, Java (JSP/Servlet), Python, ASP.NET, Node.js |
| Source code | Visible to the user (View Source) | Hidden; the user sees only the output HTML |
| Server load | Low; uses the client's CPU | Higher; the server does the work |
| Response speed | Fast for UI actions, no round trip | Needs a request-response trip |
| Database access | Cannot access it directly | Can connect to databases and files |
| Security | Less secure; user can modify code | More secure; code and data stay on the server |
| Dependence | Depends on browser support/settings | Independent of the browser |
| Typical uses | Form validation, animation, DOM changes, AJAX | Authentication, database operations, sessions, dynamic pages |
Example
Client-side (validates before sending):
<script>
function check(){
if(document.getElementById("age").value < 18){ alert("Must be 18+"); return false; }
}
</script>
Server-side (PHP creates the page and reads the database):
<?php
$name = $_POST['name'];
echo "Welcome, " . htmlspecialchars($name);
?>
In practice both are used together: JavaScript gives quick feedback, and PHP re-validates and stores the data.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Server side languages and multi-tier architecture · Web Technology, chapter 3
- Internet vs WWW; client-server paradigm · Web Technology, chapter 1
- Server-side programming and Java Servlet · Web Technology, chapter 3
- Short note: Server side programming · Web Technology, chapter 3
- Client-server versus distributed object architecture · Software Engineering, chapter 3
- Multiprocessor versus client-server architecture · Software Engineering, chapter 3
- Server before client; TCP reliability · Computer Networks and Security, chapter 5 · asked 2×
- Short note: Client-Server and Master-Slave · Big Data Technologies, chapter 1