📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (176K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
The Syntax of JSP Expression Tag
<%= expression %>
How It Works
JSP Expression Tag Examples
Convert String to Upper Case Example
<html>
<body>
Converting a string to uppercase:
<%=new String("Hello World").toUpperCase()%>
</body>
</html>
Converting a string to uppercase: HELLO WORLD
Mathematical Expressions Example
<html>
<body>
25 multiplied by 4 equals
<%=25 * 4%>
</body>
</html>
25 multiplied by 4 equals 100
Boolean Expressions Example
<html>
<body>
Is 75 less than 69?
<%=75 < 69%>
</body>
</html>
Is 75 less than 69? false
Complete Example with Output
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Converting a string to uppercase:
<%=new String("Hello World").toUpperCase()%>
<br />
<br />
Port of Server :
<%= request.getLocalPort() %>
<br />
<br />
Context path :
<%= application.getContextPath() %>
<br />
<br />
25 multiplied by 4 equals
<%=25 * 4%>
<br />
<br /> Is 75 less than 69?
<%=75 < 69%>
</body>
</html>
Real-time Examples
<%=request.getAttribute("projectName")%>
<%= application.getAttribute("MyName") %>
public class Task {
private int id;
private String name;
// getter and setters
<%= task.getName() %>
<%= task.getId() %>
Comments
Post a Comment
Leave Comment