Java JSP – Using Abstract Class

<HTML>
    <HEAD>
        <TITLE>Using Abstract Classes</TITLE>
    </HEAD>

    <BODY>
        <H1>Using Abstract Classes</H1>

        <%!
            javax.servlet.jsp.JspWriter localOut;

            abstract class a {
                abstract String getText() throws java.io.IOException;

                public void printem() throws java.io.IOException {
                    localOut.println(getText());
                }
            }

            class b extends a {
                String getText() throws java.io.IOException {
                    return "Hello from JSP!";
                }
            }
        %>
        <%
            localOut = out;     

            b bObject = new b();

            bObject.printem();
        %>
    </BODY>
</HTML>

Java JSP – JSTL Date Format Example

This example show how to format date in JSP using format tag library.

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
</head>

<body>
    <jsp:useBean id="date" class="java.util.Date"/>
    Today is: <fmt:formatDate value="${date}" type="date" pattern="dd-MMM-yyyy"/>
</body>

</html>

Java JSP – Comments Example

Following is the syntax of JSP comments:

<%-- This is JSP comment --%>

Following is the simple example for JSP Comments:

<html>
<head><title>A Comment Test</title></head>
<body>
<h2>A Test of Comments</h2>
<%-- This comment will not be visible in the page source --%>
</body>
</html>

Page 1 of 3123