Client Server Architectures and Web Programming: Two-tier and three-tier client server architectures, web servers, HTML and XML, style sheets, client side scripting: JavaScript and VBScript, server side scripting: PHP, JSP and ASP.NET programming for creating dynamic web pages using database, forms and session, AJAX and SignalR.
Three tiers
Presentation (client) → Application / business logic (middle tier, app server) → Data (DBMS)
2-tier vs 3-tier
2-tier: fat client sends SQL straight to the DB · 3-tier: thin client → app server (rules, pooling) → DB
Port numbers
HTTP 80 · HTTPS 443 · alternate HTTP/Tomcat 8080 · MySQL 3306 · SQL Server 1433 · Oracle 1521
HTTP status classes
1xx informational · 2xx success · 3xx redirection · 4xx client error · 5xx server error
Common status codes
200 OK · 201 Created · 204 No Content · 301/302 redirect · 304 Not Modified · 401 unauthenticated · 403 forbidden · 404 not found · 408 timeout · 500 · 503
Safe / idempotent methods
Safe: GET, HEAD, OPTIONS, TRACE · Idempotent: those plus PUT, DELETE · Neither: POST, PATCH
HTTP connection timing
Non-persistent serial: (n+1) × 2 RTT · persistent: 2 RTT + n × RTT · persistent pipelined: 3 RTT
Cookie attributes
Secure = HTTPS only · HttpOnly = hidden from JavaScript · SameSite = CSRF defence · no Expires/Max-Age = session cookie
XML predefined entities
< > & ' " — only < and & must always be escaped
DTD content models
? = 0 or 1 · * = 0 or more · + = 1 or more · no mark = exactly 1 · comma = sequence · | = choice
DOM vs SAX
DOM: whole tree in memory, random access, editable · SAX: event callbacks, streaming, low memory, read-only
CSS specificity
inline 1,0,0,0 > id 0,1,0,0 > class / attribute / pseudo-class 0,0,1,0 > element / pseudo-element 0,0,0,1; !important beats all
JavaScript typeof quirks
typeof null → "object" · typeof [] → "object" · typeof NaN → "number" · typeof a function → "function"
JavaScript falsy values
false, 0, -0, 0n, "" (empty string), null, undefined, NaN — everything else is truthy
VBScript essentials
Variant only · & concatenates · \ integer division · ByRef default · Dim a(4) = 5 elements · MsgBox returns vbYes 6 / vbNo 7
PHP essentials
session_start() → $_SESSION · cookie PHPSESSID · gc_maxlifetime 1440 s · include warns, require is fatal · prepared statements stop SQL injection
ASP.NET page events
PreInit → Init → InitComplete → PreLoad → Load → control events → LoadComplete → PreRender → PreRenderComplete → SaveStateComplete → Render → Unload
ASP.NET state
ViewState in __VIEWSTATE · Session modes InProc (default), StateServer, SQLServer, Custom, Off · timeout 20 min
XMLHttpRequest readyState
0 UNSENT · 1 OPENED · 2 HEADERS_RECEIVED · 3 LOADING · 4 DONE — success when 4 and status 200
SignalR
Transports WebSockets → Server-Sent Events → Long Polling · targets Clients.All / Caller / Others / Group / User
Servlet life cycle
load → init(config) once → service() per request (doGet/doPost) → destroy() once
JSP life cycle
translate → compile → load → jspInit() → _jspService() → jspDestroy()
forward vs sendRedirect
forward: server-side, 1 request, URL kept, attributes kept. sendRedirect: browser, 2 requests, URL changes
JSP include
<%@ include %> = translation time (static); <jsp:include> = request time (dynamic)
JSP scripting tags
<%! decl %> field; <% scriptlet %> in _jspService; <%= expr %> out.print; <%-- comment --%>
9 implicit objects
request, response, out, session, application, config, pageContext, page, exception (error pages only)
Session defaults
JSESSIONID cookie; web.xml timeout in minutes (30); setMaxInactiveInterval in seconds; encodeURL for rewriting
MVC Model 2
Servlet = controller, JavaBean = model, JSP (EL + JSTL) = view