The code put inside the JSP expression tag is written to the output stream of the response. So you don’t have to write out.print() to write data. It is importantly made in use to print the values of variables or ways.
<%= statement %>
We display the easy and simple Welcome message with the jsp expression tag in this example.
<html> <body> <%= "welcome to jsp" %> </body> </html>
Note: In case of expression tag please don’t end your statement with a semicolon
We have to make use of the getTime() method of the Calendar class, to show the current time. The getTime() is an instance method of the Calendar class, so it is also known as after getting the instance of the Calendar class by the getInstance() method.
<html> <body> Current Time: <%= java.util.Calendar.getInstance().getTime() %> </body> </html>
We are printing the username by making use of the expression tag, in the below given example. The index.html file has the username and forwards the request to the welcome.jsp file, which shows the username.
<html> <body> <form action="welcome.jsp"> <input type="text" name="uname"><br/> <input type="submit" value="go"> </form> </body> </html>
<html> <body> <%= "Welcome "+request.getParameter("uname") %> </body> </html>