WHAT'S NEW?

Expressions-JSP


-JSP expression automatically print out whatever is being sent between the tags.
-Expressions are evaluated and output is sent to the browser.
-Expressions are later resolved and consumed by HTML itself.
<%= expression %>[Anything which comes on right hand side int i=1;
int z=x+y;
Date dt =new Date();



Point To REMEMBER:
NO semi-colon at the end.
Ease of using Expressions.
Without expression:
 
<%@ page import="java.util.* %>
<html>
<body>
Date: <% out.println(new Date());%>
</body>
</html>

With expression:
 
<%@ page import="java.util.*" %>
<html>
<body>
Today's Date:<%=new Date() %>
</body>
</html>

-Whenever container encounters expression, Container takes everything typed between the <%= %> and put it as an argument in out.println() <%= new Date() %>Becomes
out.println(new Date());
Tip for Students:
You people always by mistake put up a semi-colon at the end which result in
<%= new Date(); %>
Becomes
out.println(new Date(););
Which becomes error then.
Hence,No semi-colon(;) at the end of Expression.
FirstJSP.jsp
 
<%@ page import="java.util.*" %>
<html>
<body>
<%@ include file="Header.html" %>
<b>
<Hello User!!!Welcome to the world of  JSP !!
</b>




Current Date : <%= new Date() % > 
<%@ include file="Footer.html"  %>
</body>
</html>

0 comments:

Post a Comment