GTU WTAD Practical 35 : JSP Page directives Example

GTU WTAD Practical 35 : Write a JSP Page to use JSP’s Page directives.

GTU WTAD Practical 35

Hope you have understand the basic concepts about jsp programming. Here I would like to explain jsp page directive with example. Check our jsp page directive with example and leave your comments. JSP Page directive is used to give direction to page for import or contenttype related features.

Jump to GTU WTAD Practical 36

File Name : index.jsp

File Location : Tomcat_Apache\webapps\gtu35\

<%@ page import="java.util.*;" %>
<%@ page contentType="text/html" %>

<!-- use of contentType Attibute -->
<%@ page errorPage="404.jsp" %>

<html>
	<head>
		<title>GTU WTAD Practical 35</title>
	</head>
	<body>
	
	<h2 align="center"> GTU WTAD Practical 35 : Write a JSP Page to use JSP's Page directives.   </h2>
	<br><br>
	
	<%="Random Number (using page directive and import attribute) :" %>
	<%=Math.random() %>
	
	<br><br>
	<b>Few More Attributes:</b> <br>
	
	
		&lt%@ page isErrorPage="true" %&gt
		<br>
		&lt%@ page info="Some Message" %&gt
		<br>
		&lt%@ page autoFlush="false" %&gt
		<br>
		&lt%@ page buffer="sizekb" %&gt
	
	</body>
</html>

 

 

File Name : 404.jsp

File Location : Tomcat_Apache\webapps\gtu35\

<%@ page contentType="text/html" %>
<!-- use of contentType Attibute -->

<%@ page errorPage="404.jsp" %>

<html>
	<head>
		<title>GTU WTAD Practical 35</title>
	</head>
	<body>
	
	<h2 align="center"> This is Custom Error Page    </h2>
	<br><br>
	
	
	
		
	</body>
</html>

 

File Name : web.xml

File Location : Tomcat_Apache\webapps\gtu35\WEB-INF

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  version="3.0"
  metadata-complete="true">  
  
  <display-name>GTU WTAD Practical 35  </display-name>
  <description>Write a JSP Page to use JSP's Page directives. </description>
  

</web-app>

 

Output

GTU WTAD Practical 35

Leave a Reply