YE01‐Without html tag - zhamri/CSC584-Enterprise_Programming GitHub Wiki
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
Name: ${student.name} <br>
Matric No: ${student.matricNo} <br>
Program: ${student.program}
</body>
</html>Name: ${student.name} <br>
Matric No: ${student.matricNo} <br>
Program: ${student.program}Both codes are converted to Servlet like:
out.write("Name: ");
out.write(student.getName());
out.write("<br>");So:
- Expression Language (EL) works the same in both
- Output is the same
- ✔ Valid HTML document
- ✔ Can open directly in browser
- ✔ Recommended for full page
- ✔ Works inside JSP
- ❌ Not a complete HTML page
- ❌ Not ideal as standalone page
| Use Case | Recommended |
|---|---|
| Full page | Code 1 |
| Included fragment (header/footer) | Code 2 |
| AJAX response | Code 2 |
- Always use Code 1 for main JSP page
- Use Code 2 for reusable parts
include header/footer
<jsp:include page="header.jsp"/>
header.jsp usually looks like this (no tag):
<h1>Welcome</h1>