buffer attribute in JSP page directive

This attribute is used to define the buffer size. Syntax: &lt Example: welcome.jsp <%@ page buffer="32kb" %>   <html> <head> <title>buffer page directive example</title> </head> <body> <h3>Hello this is a buffer page directive example.</h3> </body> </html><%@ page buffer="32kb" %> <html> <head> <title>buffer page directive example</title> </head> <body> <h3>Hello this is a buffer page directive example.</h3> … Read more

Categories JSP

Session attribute of JSP page directive

This attribute checks whether JSP page is in a particular HTTP session or not. It can have true or false value. Default value is true. Syntax: &lt Example: welcome.jsp <%@ page session="true" %>   <html> <head> <title>session page directive example</title> </head> <body> <h3>Hello this is a session page directive example.</h3> <% out.print("Session id:" + session.getId()); … Read more

Categories JSP

import attribute of JSP page directive

This attribute is used to import interface, classes or whole package. You can import more than one package separated by commas. Syntax: &lt Example: welcome.jsp <%@ page import="java.util.Date" %>   <html> <head> <title>import page directive example</title> </head> <body> Current date: <%= new Date() %> </body> </html><%@ page import="java.util.Date" %> <html> <head> <title>import page directive example</title> … Read more

Categories JSP

JSP directives

JSP directives provides the instructions and directions to the web container about how to control the processing JSP page. Syntax: &lt Types of JSP directives. page directive. include directive. taglib directive. JSP page directive: Page directive is used to provide the instructions to the web container that are specific to the current JSP page. It … Read more

Categories JSP

JSP comment tag

JSP comment tag is used to marks jsp code as comment i.e. the code inside comment tag will be ignored by web container. Syntax: &lt Example: welcome.jsp <html> <head> <title>Comment tag example</title> </head> <body> This is Comment tag example. Next line is commented so will not be visible. <!– Hello World –> </body> </html><html> <head> … Read more

Categories JSP

JSP Expression tag

Expression tag evaluates the scripting language expression, converts the result into a string. This result is send back to the web user through response object. It writes the result into output stream of the response object. Syntax: &lt Example: welcome.jsp <html> <head> <title>Expression tag example</title> </head> <body> Sum of 10 and 20 = <%= 10 … Read more

Categories JSP

JSP Declaration tag

Declaration tag is used to declare one or more variables or methods at class level. Variables and methods declare in declaration tag are initialized at the time of JSP initialization. These variables and methods are kept outside of the service method by web container to make them class level. Syntax: &lt Example: welcome.jsp <html> <head> … Read more

Categories JSP

JSP Scriptlet tag

Scriptlet tag contains the any no. of java code statements. It may contain variables declaration or valid expressions. When JSP is translated into servlet, java code written in the scriplet tag is moves to the _jspService() method by web container.   Syntax: <% java code %><% java code %> Note: Variable and methods declare in … Read more

Categories JSP

JSP Hello World Example

Let us start the JSP programming with a simple program to show “Hello World” on a jsp page. Create welcome.jsp and put its entry into web.xml file. Example: welcome.jsp <html> <head> <title>Welcome</title> </head> <body> <h1>Hello World.</h1> </body> </html><html> <head> <title>Welcome</title> </head> <body> <h1>Hello World.</h1> </body> </html> web.xml <web-app>   <welcome-file-list> <welcome-file>welcome.jsp</welcome-file> </welcome-file-list>   </web-app><web-app> <welcome-file-list> … Read more

Categories JSP