< Prev
Next >



JSP info Attribute





info Attribute


As we know that every JSP web page is automatically translated to its equivalent Servlet. In JSP, the info attribute allows us to set a String message about the current JSP page, this message could be retrieved and read using the translated Servlet's getServletInfo method.



Syntax of info Attribute


<%@ page info = "A message" %>





info Attribute Example


In the upcoming example, we are setting info attribute of page directive with a message, this message will be displayed by calling getServletInfo() method of the Servlet(translated from this JSP).

Info.jsp
<html>

<head>

<title>
JSP info attribute
</title>

</head>


<body>

<%@ page  info ="Decodejava.com is an online portal An online portal that provides 
easy tutorials of Java programming language." %>

<h2>Information about JSP page</h2>

<%= getServletInfo() %> <br/>

</body>

</html>



executing this JSP page gives us an information set by the info attribute by using getServletInfo() method of javax.servlet.Servlet class.






Note


You could place page directive containing info attribute or any of its attributes, inside/outside the tag of html or even at the beginning of the JSP file and result will still be the same. For example - let's see what happens when we place the page directive containing the info attribute at the beginning of the JSP file.

Info2.jsp
<%@ page  info ="Decodejava.com is an online portal An online portal that provides 
easy tutorials of Java programming language." %>

<html>

<head>

<title>
JSP info attribute
</title>

</head>


<body>

<h2>Information about JSP page</h2>

<%= getServletInfo() %> <br/>

</body>

</html>


We leave the result for you to find out.


Please share this article -

Facebook Google Pinterest Reddit Tumblr Twitter



< Prev
Next >
< JSP session Attribute
JSP isErrorPage & errorPage Attribute >

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page

Notifications



COMING SOON
-
PYTHON