JSP tutorial syntax

JSP Syntax:



I feel that it is always useful to take a look at the simple syntactical constructs of a technology before we dig deep into it. Well, whether you agree or disagree, below is a synopsis of the JSP syntax. You can use it to get a feel of what we are going to learn in the next few chapters…



Syntax What it Represents Example
< ! -- comment -- > HTML Comment < ! -- This HTML comment is passed through to the client -- >
<%-- comment --%> JSP Comment <%-- This comment is ignored by the server --%>
<%@ page [key]="[value]" %> Page Directive <%@ page import="java.util.*" %>
<%! Declaration %> Declaration <%! String name = new String ("Rocky"); %>
<%= expression %> Expression Your shopping cart total is: <%= shoppingCart.getTotal() %>.
<% code %> Scriptlet <% String password =request.getParameter("password"); if ( password == null) { %>


Password is required, thank you.

<% } %>

<%@ include file="file" %> Static include, parsed at compile-time <%@ include file="welcome.jsp>
< jsp : include page="file" / > Dynamic include, request-time and not parsed < jsp : include page="welcome.html" / >

 
Top Blogs