Unit 3 Chapter 2
Unit 3 Chapter 2
Chapter 2
JSP Comments
JSP comment marks text or statements that the JSP container should ignore. A JSP comment is useful when you want to hide
or "comment out", a part of your JSP page.
Following is the syntax of the JSP comments −
<%-- This is JSP comment --%>
Eg:
<html>
<body>
<%-- This comment will not be visible in the page source --%>
</body>
</html>
There are a small number of special constructs you can use in various cases to insert comments or characters that would
otherwise be treated specially. Here's a summary −
Elements of JSP
The elements of JSP have been described below −
● scriptlet tag
● expression tag
● declaration tag
The Scriptlet
A scriptlet can contain any number of JAVA language statements, variable or method declarations, or expressions that are valid in the page scripting
language.
Following is the syntax of Scriptlet −
<% code fragment %>
You can write the XML equivalent of the above syntax as follows −
<jsp:scriptlet>
code fragment
</jsp:scriptlet>
1. <html>
2. <body>
3. <form>
4. <%
5. String name=request.getParameter("uname");
6. out.print("welcome "+name);
7. %>
8. </form>
9. </body>
10. </html>
JSP expression tag
The code placed within JSP expression tag is written to the output stream of the response. So you need not write out.print() to write data.
It is mainly used to print the values of variable or method.
home.jsp
<body>
</body>
</html>