Java Server Pages - Expression Tag, Directive Tag, Inline Comments
Java (current. Jakarta) Server Pages is a framework used for web application development.
This post will discuss:
- Expression Tag
- Directive Tag
- Inline Comment Types
Expression Tag
<%= %> Expression tags allow JSP code to be output directly into the document code stream. Therefore, any output from JSP does not need to be explicitly printed.
<%
out.println("name:"+name+"<br>");
out.println("age:"+age+"<br>");
out.println("area:"+areaCircle(5));
%>
<br> *SAME AS*
name:<%= name %><br>
age:<%= age %><br>
area: <%= areaCircle(5) %>
Directive Tag
<%@ %> The Directive Tag contains commands for running the JSP page in the servlet.
Language:
Defines scripting language. Default is “java”
contentType:
Defines MIME, character set.
pageEncoding:
Encoding. Set to UTF-8 for international language support.
Inline Comment Types
Since Java and HTML are being used simultaneously, all forms of comment tags are available for use:
- //
- /* */
- <!-- -->
- <%-- --%>
As the functionality of JSP suggests, Java comments are not exposed to the client browser, while HTML comments can be read by the client browser. (i.e. seen through inspect element)
-gonkgonk