Saturday, 2 December 2017

How to include one jsp file into another jsp file body to display data java jsp programming code

Learning Java Programming Made Easy


Page 1: Hit Counter (jsp page)

/*******hits.jsp*******//
<%-- 
    Document   : hits
    Created on : Nov 30, 2016, 11:54:25 AM
    Author     : admin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<body>
<%
    Integer hitsCount = (Integer)application.getAttribute("hitCounter");
    if( hitsCount ==null || hitsCount == 0 ){
       out.println("first time!");
       hitsCount = 1;
    }else{
       /* return visit */
       out.println("Welcome back!");
       hitsCount += 1;
    }
    application.setAttribute("hitCounter", hitsCount);
%>
<p>Total number of visits: <%= hitsCount%></p>
</body>
</html>



/***********************************************************//


Page 2: (jsp file)


/************main.jsp**************/


<%-- 
    Document   : main
    Created on : Nov 30, 2016, 12:04:52 PM
    Author     : admin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<body>
<jsp:include page="hits.jsp" flush="true" />
</body>
</html>



No comments:

Post a Comment

Welcome, happy learning

Charactor_At_Position

public class Char_At_Position { public static void main(String[] args) { String str = "Wankhede"; String rev=""...