HTML ยท CSS ยท XML ยท XHTML ยท JavaScript ยท JSP
HTML stands for HyperText Markup Language โ it's the skeleton ๐ฆด of every webpage. It tells the browser what content to display and how to structure it.
<tag> and closing </tag>/<br>, <img>, <hr>, <input>Every HTML page must follow this standard structure. Without it, browsers may render your page incorrectly!
Tells browser this is HTML5. Must be the very first line. Case insensitive.
Root element โ wraps absolutely everything. lang attr helps screen readers.
Contains metadata (info about the page). Nothing here is visible to users. Links to CSS, JS go here.
Contains ALL visible content โ headings, paragraphs, images, links, forms, etc.
Add styling directly using the style attribute. This is inline CSS โ use sparingly!
color ยท background-color ยท font-size ยท font-family ยท text-align ยท margin ยท padding ยท border ยท width ยท height
The building blocks of HTML. An element = opening tag + content + closing tag.
Examples: <p>, <h1>, <img>, <div>, <span>
Provide extra information. Always go inside the opening tag. Format: name="value"
| Attribute | Purpose | Example |
|---|---|---|
id | Unique identifier for ONE element | id="header" |
class | Group identifier (reusable, multiple) | class="btn active" |
src | Source file path (img, script, iframe) | src="logo.png" |
href | Hyperlink destination | href="page.html" |
alt | Alternative text (accessibility) | alt="Logo image" |
title | Tooltip text on hover | title="Click here" |
style | Inline CSS styling | style="color:red" |
width/height | Element dimensions | width="300" |
disabled | Disables form element | disabled |
required | Field must be filled | required |
placeholder | Hint text in inputs | placeholder="Name..." |
value | Default/submitted value | value="Submit" |
target | Where link opens | target="_blank" |
action | Form submission URL | action="process.php" |
method | Form HTTP method | method="post" |
type | Input/button type | type="email" |
HTML5 introduced semantic layout elements โ tags that carry meaning about the content they hold, improving accessibility and SEO.
An iFrame (inline frame) embeds another HTML page or external resource within the current page.
| Attribute | Description |
|---|---|
src | URL of page to embed |
width/height | Size in pixels or % |
title | Accessibility description |
allowfullscreen | Allows fullscreen mode |
name | Target name for links |
sandbox | Security restrictions |
loading="lazy"` | Lazy load for performance |
Forms collect user data and send it to a server for processing. Every interactive website uses forms!
Every HTML element is treated as a rectangular box with 4 layers. Understanding this is essential for layouts!
@media print, @media screen)@font-face)border-collapse, border-spacing)::before, ::after, content)| Value | Behavior | Offset from |
|---|---|---|
static | Default. Normal document flow | N/A |
relative | Offset from its own normal position | Itself |
absolute | Removed from flow, positioned relative to nearest positioned ancestor | Positioned parent |
fixed | Stays in place while scrolling | Viewport |
sticky | Relative until scroll threshold, then fixed | Viewport |
XML (eXtensible Markup Language) is designed for storing and transporting data. Unlike HTML which displays data, XML describes data with custom tags you define yourself.
| HTML | XML |
|---|---|
| Fixed predefined tags | Custom tags you define |
| Case insensitive | Case SENSITIVE (<Name> โ <name>) |
| Some tags can be unclosed | ALL tags MUST be closed |
| Focuses on presentation | Focuses on data/content |
| Browser renders it | Parsed by applications |
DTD defines the structure and legal building blocks of an XML document. It's a blueprint โ says which elements/attributes are allowed.
XML Schema is a more powerful alternative to DTD. Written in XML itself. Supports data types, namespaces, and complex validation.
xs:string ยท xs:integer ยท xs:decimal ยท xs:boolean ยท xs:date ยท xs:time ยท xs:anyURI
DOM represents XML/HTML documents as a tree structure in memory, allowing programs to access and modify any part of the document.
getElementById("id") โ Find single element by IDgetElementsByTagName("p") โ Find elements by tag (returns list)getElementsByClassName("cls") โ Find by class (returns list)querySelector(".cls") โ First match (CSS selector syntax)querySelectorAll("p.note") โ All matchescreateElement("div") โ Create new elementappendChild(elem) โ Add child at endremoveChild(elem) โ Remove child elementsetAttribute("attr","val") โ Set attributegetAttribute("src") โ Get attribute valueXHTML (eXtensible HyperText Markup Language) is HTML written according to XML rules. It's stricter, cleaner, and more maintainable than regular HTML.
| HTML (Forgiving) | XHTML (Strict) |
|---|---|
<p>text โ unclosed OK | <p>text</p> โ must close all tags |
<BR> uppercase OK | <br /> must be lowercase |
<input type=text> no quotes | <input type="text" /> quotes required |
| Attributes without values allowed | All attributes must have values |
| Tags can overlap | Tags must be properly nested |
Special characters that cannot be typed directly in HTML (reserved or special symbols):
| Entity | Symbol | Name |
|---|---|---|
< | < | Less than |
> | > | Greater than |
& | & | Ampersand |
" | " | Double quote |
' | ' | Apostrophe |
| (space) | Non-breaking space |
© | ยฉ | Copyright |
® | ยฎ | Registered trademark |
™ | โข | Trademark |
€ | โฌ | Euro sign |
£ | ยฃ | Pound sign |
© | ยฉ | Numeric entity (decimal) |
© | ยฉ | Hex entity |
Frames divide the browser window into multiple independent sections. Deprecated in HTML5 โ use iframes instead.
<iframe> for embedding specific external content.
JavaScript is a programming language that runs in web browsers, making websites interactive and dynamic. It's the language of the web!
Objects are containers that group related data and functions. Like a person โ they have properties (name, age) and actions (talk, walk).
| Type | Example | Notes |
|---|---|---|
| Number | 25, 3.14, -7, Infinity, NaN | Only ONE number type (unlike Java) |
| String | "Hello", 'World', `Template` | Single, double, or backtick quotes |
| Boolean | true, false | Lowercase only |
| Undefined | let x; | Declared but no value assigned |
| Null | let y = null; | Intentionally empty |
| BigInt | 9007199254740991n | Very large integers |
| Symbol | Symbol("id") | Unique identifiers |
Arrays are like numbered boxes โ they store multiple values in a single variable. Index starts at 0!
Functions are reusable blocks of code โ like a recipe. Write once, use many times!
DOM = Document Object Model. It's how JavaScript sees, accesses, and modifies the HTML document as a tree of objects.
JSP (Java Server Pages) creates dynamic web pages using Java. Runs on the SERVER. Combines HTML with Java code!
jspInit() โ Called once when JSP is first loadedjspService() โ Called on EVERY requestjspDestroy() โ Called when JSP is removed from service| Element | Syntax | Purpose |
|---|---|---|
| Directive | <%@ ... %> | Page-level instructions to container |
| Declaration | <%! ... %> | Declare variables and methods |
| Scriptlet | <% ... %> | Any Java code (logic, loops) |
| Expression | <%= ... %> | Output value to HTML (no semicolon!) |
| Comment | <%-- ... --%> | JSP comments (not in output) |
| Action | <jsp:... /> | Standard actions (useBean, include) |
<%! ... %>Declare variables and methods that belong to the Servlet class (not jspService). Available throughout the entire JSP page.
<%@ ... %>Special instructions for the JSP container. Processed at translation time (before execution).
<%= ... %>Outputs a value directly to HTML. The expression is automatically converted to a String. NO semicolon!
<% ... %>Embed any Java code for logic, loops, and conditions.
JSP provides 9 pre-built objects automatically available in every JSP page. No need to create them!
| Object | Type | Scope | Purpose |
|---|---|---|---|
request | HttpServletRequest | Request | HTTP request data, parameters, headers |
response | HttpServletResponse | Page | HTTP response, cookies, redirect |
session | HttpSession | Session | User session data (across multiple pages) |
application | ServletContext | Application | App-wide data shared by all users |
out | JspWriter | Page | Output stream โ write to response |
page | Object | Page | Current JSP page instance (= this) |
pageContext | PageContext | Page | Access to all other implicit objects |
config | ServletConfig | Page | Servlet config parameters |
exception | Throwable | Page | Exception info (error pages only) |
JavaBeans are simple Java classes that represent and carry data. They follow specific conventions making them easy to use in JSP.
Small data stored in the user's browser. Sent with every request. Max ~4KB. Not secure for sensitive data. Persist across browser sessions if max-age set.
Data stored on the server. More secure. Browser just stores a session ID (JSESSIONID cookie). Expires when browser closes or timeout.
JDBC (Java Database Connectivity) lets JSP communicate with databases like MySQL, Oracle, PostgreSQL.
Always use PreparedStatement for INSERT/UPDATE with user data โ prevents SQL Injection attacks!
DBConnection.java utility class to manage connections, and consider using a Connection Pool (like HikariCP or C3P0) in production apps for better performance!