In this tutorial you will learn about the JSP Expressions.
Jsp expressions
In this tutorial you will learn about the JSP Expressions.
JSP expressions are the expressions which contains the scripting language expression value. To display a scripting language expression's value as part of HTML page that will be returned to the client as a response after converting into the data stream JSP expressions are used. An expression written in java language JSP expression inserts java values directly into the output i.e in Java scripting language JSP expression behaved as a statement and changed the expression's value as a String object and wrapped it into the implicit out object.
Syntax :
<%= expr %>
Here 'expr' is an expression that will be wrapped to implicit out object.
Here I am going to give an example which will demonstrate you how expressions are used in JSP.
Example :
name.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>JSP Expressions Example</title> </head> <body> <form> Name <input type="text" name="text"/> <input type="submit" value="submit"/> </form> <%String name= request.getParameter("text");%> <% if(name!=null) {%> <%=name %> <%} %> </body> </html>
Output :
When you will execute this example an output will be as following :
1. A page will be opened with containing text box and submit button
2. When you will enter the value as per the instruction and after clicking on submit button the text that you have entered will be appear to you.
[ 0 ] Comments