postheadericon example of page directive in jsp

index.jsp

<html>
<head>
<title>EX-35</title>
</head>
<body>
<%@ page language="java" %>
<%@ page info="A code from www.BipinRupadiya.com"  %>
<ul>
<li><a href="import.jsp">Example of page directive import </a></li>
<li><a href="isThreadsafe.jsp">Example of page directive isThreadsafe </a></li>
<li><a href="jsp-forward.jsp">Example of page directive jsp-forward </a></li>
<li><a href="contentType.jsp">Example of page directive contentType </a></li>
<li><a href="errorPage.jsp">Example of page directive isErrorPage and errorPage </a></li>
</ul>
<body>
</html>






import.jsp

<%@ page import="java.util.*"%>

<UL>
<%Date d= new Date();%>
  <LI>Current time: <%=d %>
  <LI>Server: <%= application.getServerInfo() %>
  <LI>Session ID: <%= session.getId() %>
  <LI>The testParam form parameter:
      <%= request.getParameter("testParam") %>
</UL>




isThreadsafe.jsp

<%@ page isThreadSafe="true"%>
<%! private int idNum = 0; %>
<%
//synchronized(this)
{
String userID = "userID : " + idNum;
out.println("Your " + userID + ".");
idNum = idNum + 1;
}
%>

jsp-forward.jsp

<% String destination;
if (Math.random() > 0.5)
{   destination = "/p1.jsp"; }
else
{ destination = "/p2.jsp"; }
%>
 <jsp:forward page="<%= destination %>" />
<!-- make p1.jsp and p2.jsp as dummy file -->



contentType.jsp

<!-- produce out in an excel file -->
<%@page contentType="application/vnd.ms-excel" %>
<%
out.print("wwww"+"\t"+"Bipin"+"\t"+"Rupadiya.com");
%>




errorPage.jsp

<%@ page errorPage="ediv.jsp" %>
<%=10/0%>

ediv.jsp

<%@ page isErrorPage="true" %>

we can not divide any number with ZERO

0 comments:

Follow by Email

Blog Archive

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.