Introduction to JSP Java Server Pages Ziad A

  • Slides: 53
Download presentation
Introduction to JSP Java Server Pages Ziad A. Al-Sharif

Introduction to JSP Java Server Pages Ziad A. Al-Sharif

Overview • Java Server Pages (JSP) is a server-side programming technology that enables the

Overview • Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic, platform-independent method for building Web-based applications. • Allows the development of Webpages that supports dynamic content. • Allows java code in HTML pages by making use of special JSP tags such as: • start with <% and end with %>. • Enabled by Java Servlet that is designed to fulfill the role of a user interface for a Java web application. • JSP technology has facilitated the segregation of the work of a Web designer and a Web developer. • A Web designer can use HTML to design and formulate the layout for the Web page • A Web developer can work independently and use java code and JSP specific tags to implement the business logic • The simultaneous construction of the static and dynamic content facilitates development of quality applications with increased productivity.

What is JSP • Scripting elements are used to provide dynamic pages • JSP

What is JSP • Scripting elements are used to provide dynamic pages • JSP simply puts Java inside HTML pages. • You can take any existing HTML page and change its extension to “. jsp” instead of “. html”. • On the other hand, Servlets are pure Java programs. They introduce dynamism into web pages by using programmatic content. • Two major components of JSP: • Static content: • provided by HTML or XML • Dynamic content: • generated by JSP tags and scriplets written in Java language to encapsulate the application logic.

Why Use JSP? • Performance is significantly better because JSP allows embedding Dynamic Elements

Why Use JSP? • Performance is significantly better because JSP allows embedding Dynamic Elements in HTML pages itself • JSP page are always compiled before they are processed by the server • JSP pages are built on top of the Java Servlets API, so like Servlets, JSP also has access to all the powerful Enterprise Java APIs, including JDBC, EJB, etc. • JSP vs. Pure Servlets: it is more convenient to write (and to modify!) regular HTML than to have plenty of println statements that generate the HTML. • JSP pages can be used in combination with servlets that handle the business logic, the model supported by Java servlet template engines. • JSP is an integral part of Java EE, a complete platform for enterprise class applications.

JSP and Servlets • JSP technology is an extension/wrapper over the Java servlet technology.

JSP and Servlets • JSP technology is an extension/wrapper over the Java servlet technology. • A JSP page , after compilation, generates a servlet and therefore incorporates all servlet functionalities. • Servlets and JSP thus share common features, such as: • platform independence (java based) • creation of database-driven Web applications • and server side programming capabilities. • However, there also some basic differences between servlets and JSPs

JSP vs. Servlets • Servlets tie up files to independently handle the static presentation

JSP vs. Servlets • Servlets tie up files to independently handle the static presentation logic and the dynamic business logic. • an HTML file for the static content and • a Java file for the dynamic contents • a change made to any file requires recompilation of the servlet • JSP on the other hand allows Java to be embedded directly into an HTML page by using tags • The HTML content and the Java content can also be placed in separate files. • Any changes made to HTML content is automatically compiled and loaded onto the servlet • Servlet can be viewed as “HTML inside Java”, which is better for implementing business logic - as it is Java dominant. JSP, on the other hand, is “Java inside HTML”, which is superior for creating presentation - as it is HTML dominant.

JSP vs. Servlets • Servlet programming involves extensive coding • Therefore, any change made

JSP vs. Servlets • Servlet programming involves extensive coding • Therefore, any change made to the code requires identification of the • static code content (for the designer) and • dynamic code content (for the developer) to facilitate incorporation of the changes. • A JSP page, by virtue of the separate placement of the static and dynamic content: • facilitates both Web developers and the Web designer to work independently. • That is to say, anything that can be done using JSPs can also be accomplished using Java servlets. However, it is important to note that servlets and JSPs are complementary technologies, NOT replacement of each other.

JSP - Architecture • The web server needs a JSP engine, a container to

JSP - Architecture • The web server needs a JSP engine, a container to process JSP pages • The JSP container is responsible for intercepting requests for JSP pages • A JSP container works with the Web server to provide the runtime environment and other services a JSP needs

JSP Life Cycle • When the client (web browser) requests a particular JSP page

JSP Life Cycle • When the client (web browser) requests a particular JSP page • the server in turns sends a request to the JSP engine • The JSP engine is part of a Web container, that compiles a JSP page to a servlet • Each JSP page is turned into a Java servlet, compiled and loaded • This compilation happens on the first request. • After the first request, the file doesn’t take long to load anymore • Every time you change the JSP file, it will be re-compiled again • The following figure represents the process of the flow of events that occur after a client requests for a JSP page

Request-Response Cycle for a JSP Page Response Servlet reloaded No Request Browser Web Container

Request-Response Cycle for a JSP Page Response Servlet reloaded No Request Browser Web Container ( JSP Engine ) Response Check to ensure if the call to JSP is first of its kind Yes Response Servlet generation and recompilation

Request-Response Cycle for a JSP Page • The request-response cycle essentially comprises of two

Request-Response Cycle for a JSP Page • The request-response cycle essentially comprises of two phases: • the translation phase and • the request-processing phase. • The translation phase is implemented by the JSP engine and involves generation of a servlet. • Internally , this results in the creation of a class file for the JSP page, that implements the servlet interface. • During the request-processing phase: • the response is generated according to the request specifications • After the servlet is loaded for the first time: • it remains active • processes all the subsequent requests , • and saves time that would otherwise be lost in reloading a servlet at each time.

JSP compilation into Servlets JSP Initial request Web Browser Web Server J 2 EE

JSP compilation into Servlets JSP Initial request Web Browser Web Server J 2 EE Web Container Subsequent request translation Java Servlets

Request-Response Cycle for a JSP Page

Request-Response Cycle for a JSP Page

JSP Methods Once a JSP is translated to a servlet , the container invokes

JSP Methods Once a JSP is translated to a servlet , the container invokes the following life cycle methods on the servlet , that are defined in the javax. servlet. jsp. Jsp. Page interface: • jsp. Init() : This method is invoked at the time when the servlet is initialized • _jsp. Service() : This method is invoked when request for the JSP page is received • jsp. Destroy() : This method is invoked before the servlet is removed from the service

JSP Scripting elements

JSP Scripting elements

JSP comments <%-- JSP comment--%> • JSP comments are similar to HTML comments •

JSP comments <%-- JSP comment--%> • JSP comments are similar to HTML comments • <!-- HTML comment -- > • except JSP comments are never sent to the user’s browser • HTML comments are visible in the page source Index. jsp <html> <head> <title> HTML and JSP Comments </title> </head> <body> <h 2> Comments </h 2> <!-- This HTML Comment-visible in the page source --> <%-- This JSP comment-Not visible in the page source -- %> </body> </html>

Simple JSP Example <html> <head><title> Random JSP Example </title></head> <body> <center> <% %> <%

Simple JSP Example <html> <head><title> Random JSP Example </title></head> <body> <center> <% %> <% double num = Math. random(); if (num > 0. 95) { <h 2>You are having a lucky day!</h 2> <p>(<%= num %>)</p> } else { <h 2>Well, life goes on. . . </h 2> } <p>(<%= num %>)</p> %> <a href="<%= request. get. Request. URI() %>"> <h 3> Try Again </h 3></a> </center></body> </html>

About the previous Example • A JSP script is a regular HTML page containing

About the previous Example • A JSP script is a regular HTML page containing Java programs. • Recall that JSP is “Java inside HTML”, whereas servlet is “HTML inside Java”. • The Java statements are enclosed by <%. . . %> (called JSP scriptlet) or <%=. . . %> (called JSP expression). • JSP Scriptlet <%. . . %> is used to include Java statements. • JSP Expression <%=. . . %> is used to evaluate a single Java expression and display its result. • The method request. get. Request. URI() is used to retrieve the URL of the current page. This is used in the anchor tag <a> for refreshing the page to obtain another random number.

About the previous Example: Behind the Scene (Translation Phase) out. write("<html>rn "); out. write("<a

About the previous Example: Behind the Scene (Translation Phase) out. write("<html>rn "); out. write("<a href=""); double num = Math. random(); out. print( request. get. Request. URI() ); if (num > 0. 95) { out. write("<h 2>You are having a lucky day!"); out. write("</h 2><p>("); out. print( num ); out. write(")</p>rn"); out. write("">"); out. write("<h 3>Try Again</h 3></a>rn"); out. write("</html>rn"); } else { out. write("rn "); out. write("<h 2>Well, life goes on. . . "); out. write("</h 2><p>("); out. print( num ); out. write(")</p>rn "); } Explanation • The HTML statements are written out as part of the response via out. write(). • The JSP scriptlets <%. . . %> are kept, as "it is", the program logic. • The JSP expressions <%=. . . %> are evaluated and the result is placed inside out. print().

Right Click the running server and select its properties Lookup the running server properties

Right Click the running server and select its properties Lookup the running server properties and find out where it stores the translated JSP to java source file and look for the following folders (path): i. e. domain 1generatedjsp

JSP Scripting elements • The scripting elements provides the ability to insert java code

JSP Scripting elements • The scripting elements provides the ability to insert java code inside the HTML • There are three types of scripting elements: 1. Declaration tag <%! field or method declaration %> i. e. <%! int data=50; %> 2. Expression tag <%= statement %> i. e. Current Time: <%= java. util. Calendar. get. Instance(). get. Time() %> 3. Directive tag <%@ directive attribute="value" %> 4. Scriptlet tag <% java source code; %> 5. Action tag <jsp: action_name attribute = "value" /> i. e. <jsp: include page = "date. jsp" flush = "true" />

1. Declaration tag (<%! %>) • This tag allows the developer to declare variables

1. Declaration tag (<%! %>) • This tag allows the developer to declare variables or methods • Before the declaration, you must have <%! and at the end of the declaration the developer must have %> • Code placed in this Declaration tag must end in a semicolon(; ) • Declarations do not generate output, so are used with JSP expressions or scriptlets

Example 1: JSP Declaration Tag test 1. jsp <html> <body> <%! int data=50; %>

Example 1: JSP Declaration Tag test 1. jsp <html> <body> <%! int data=50; %> <%= "Value of the variable is: "+ data %> </body> </html> test 2. jsp <html> <body> <%! int cube(int n){ return n*n*n*; } %> <%= "Cube of 3 is: “ +cube(3) %> </body> </html>

2. Expression tag (<%= %>) • This tag allows the developer to embed any

2. Expression tag (<%= %>) • This tag allows the developer to embed any java expression within the HTML code • It is mostly using the out. println() • A semicolon (; ) does not appear at the end of the code inside the tag

Example 1: JSP expression tag test 1. jsp <html> <body> <%= "welcome to jsp"

Example 1: JSP expression tag test 1. jsp <html> <body> <%= "welcome to jsp" %> </body> </html> test 2. jsp <html> <body> Current Time: <%= java. util. Calendar. get. Instance(). get. Time() %> Current Date and Time is : <%= new java. util. Date() %> </body> </html>

Example 2: JSP expression tag index. jsp <html> <body> <form action=“welcome. jsp“ > <input

Example 2: JSP expression tag index. jsp <html> <body> <form action=“welcome. jsp“ > <input type =“text" name="uname“ > <input type =“submit" value="go"> </form> </body> </html> welcome. jsp <html> <body> <%= “Welcome “ + request. get. Parameter("uname") %> </body> </html>

3. Directive tag (<%@ directive…. %>) • A JSP directive gives special information about

3. Directive tag (<%@ directive…. %>) • A JSP directive gives special information about the jsp page, to the JSP Engine • There are three main types of directives: 1. page • processing information for this page 2. Include • files to be included 3. Tag library • tag library to be used in this page • Directives do not produce any visible output when the page is requested but change the way the JSP engine processes the page • For example, you can make session data unavailable to a page by setting a page directive (session) to false • more to come here? ? ?

Examples: JSP Directive • Import java packages <%@ page import="java. util. *, java. sql.

Examples: JSP Directive • Import java packages <%@ page import="java. util. *, java. sql. *" %> • Multiple import statements <%@ page import="java. util. *" %> <%@ page import="java. sql. *" %> • Including file at translation time <%@ include file="header. html" %> • For include the path is relative to the JSP file

Example of import Directive • Between <% and %> tags , any valid Java

Example of import Directive • Between <% and %> tags , any valid Java Code is called a Scriptlet. • This code can access any variable or bean declared. index. jsp <html> <body> <%@page import="java. util. Date" %> Today is: <%= new Date() %> </html>

Example of Include Directive • The include directive is used to include the contents

Example of Include Directive • The include directive is used to include the contents of any resource it may be jsp file, html file or text file. • The include directive includes the original content of the included resource at page translation time • the jsp page is translated only once so it will be better to include static resource. index. jsp <html> <body> <%@ include=“test. html" %> Today is: <%= new Date() %> </html>

4. Scriptlet Tag (<%. . . %>) • Between <% and %> tags ,

4. Scriptlet Tag (<%. . . %>) • Between <% and %> tags , any valid Java Code is called a Scriptlet. • This code can access any variable or bean declared. index. jsp <html> <body> </html> <% %> String message = “Hello World !” ; out. println(message);

Example 1: JSP Scriptlet Tag index. html <html> <body> <form action="welcome. jsp“ > <input

Example 1: JSP Scriptlet Tag index. html <html> <body> <form action="welcome. jsp“ > <input type ="text" name="uname“ > <input type ="submit" value="go"> </form> </body> </html> welcome. jsp <html> <body> <% String name = request. get. Parameter("uname"); out. print("welcome : “ + name ); %> </body> </html>

5. Action Tag • There are three main roles of the action tags: 1.

5. Action Tag • There are three main roles of the action tags: 1. Enable the use of the server side Javabeans 2. Transfer control between pages 3. browser independent support for applets • Standard actions • Example: <jsp: use. Bean>. . . </jsp: use. Bean>

JSP Implicit Objects

JSP Implicit Objects

JSP Implicit Objects • There are 9 JSP implicit objects. These objects are created

JSP Implicit Objects • There are 9 JSP implicit objects. These objects are created by the web container that are available to all the JSP pages. Object/Variable Type out javax. servlet. jsp. Jsp. Writer request javax. servlet. http. Http. Servlet. Request response javax. servlet. http. Http. Servlet. Response config javax. servlet. http. Servlet. Config application javax. servlet. http. Servlet. Context session javax. servlet. http. Http. Session page. Context javax. servlet. jsp. Page. Context page javax. lang. Object exception javax. lang. Throwable

1 -JSP implicit object: out • JSP provides the out implicit object of type

1 -JSP implicit object: out • JSP provides the out implicit object of type Jsp. Writer. • Can be used for writing any data to the buffer index. jsp <html> <body> <% out. print(2*5); %> </body> </html> index. jsp <html> <body> <% out. print("Today is: "+java. util. Calendar. get. Instance(). get. Time()); %> </body> </html>

2 -JSP implicit object: request object • The JSP request is an implicit object

2 -JSP implicit object: request object • The JSP request is an implicit object of type Http. Servlet. Request • It provides access to information associated with the request • Normally used in looking up parameter values and cookies • It is created by the web container for each jsp request • It can be used to get request information such as: • • parameter, header information, remote address, server name, server port, content type, character encoding etc. index. html welcome. jsp <html> <body> <form action="welcome. jsp“ > <input type ="text" name="uname“ > <input type ="submit" value="go"> </form> </body> </html> <body> <% String name = request. get. Parameter("uname"); out. print("welcome : “ + name ); %> </body> </html>

3 -JSP implicit object: response object • In JSP, response is an implicit object

3 -JSP implicit object: response object • In JSP, response is an implicit object of type Http. Servlet. Response. • It is created by the web container for each jsp request. • It can be used to add or manipulate response such as: • redirect response to another resource • send error etc. welcome. jsp <html> <body> <% %> </body> </html> index. html <html> <body> <form action="welcome. jsp“ > <input type ="text" name="uname“ > <input type ="submit" value="go"> </form> </body> </html> response. send. Redirect("http: //www. just. edu. jo/~zasharif/Web/SE 432. html");

4 -JSP implicit object: config • It is an implicit object of type Servlet.

4 -JSP implicit object: config • It is an implicit object of type Servlet. Config • Stores the Servlet configuration data. • It can be used to get initialization parameter for a particular JSP page. • Generally, it is used to get initialization parameter from the web. xml file. • It is created by the web container for each jsp page. index. html web. xml <html> <body> <form action="welcome. jsp“ > <input type ="text" name="uname“ > <input type ="submit" value="go"> </form> </body> </html> <web-app> welcome. jsp <html> <body> <% out. print("Welcome "+request. get. Parameter("uname")); String val = config. get. Init. Parameter(“test. Param”); out. print(“test. Param value =“ + val ); %> </form> </body> </html> <servlet-name>welcome</servlet-name> <jsp-file>/welcome. jsp</jsp-file> <init-param> <param-name>test. Param</param-name> <param-value>123456</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>welcome</servlet-name> <url-pattern>/welcome</url-pattern> <url-pattern>/welcome. jsp</url-pattern> </servlet-mapping> </web-app>

5 -JSP implicit object: application • In JSP, application is an implicit object of

5 -JSP implicit object: application • In JSP, application is an implicit object of type Servlet. Context. • It is created only once by the web container • when application or project is deployed on the server. • It can be used to get initialization parameter from the configuration file (web. xml). • It can also be used to get, set or remove attribute from the application scope. • This initialization parameter can be used by all jsp pages. index. html <html> <body> <form action="welcome. jsp“ > <input type ="text" name="uname“ > <input type ="submit" value="go"> </form> </body> </html> welcome. jsp <html> <body> <% out. print("Welcome "+request. get. Parameter("uname")); String val=application. get. Init. Parameter(“test. Val"); out. print(“The Value of test. Val=“ + val); %> </form> </body> </html> web. xml <web-app> <servlet-name>welcome</servlet-name> <jsp-file>/welcome. jsp</jsp-file> </servlet> <servlet-mapping> <servlet-name>welcome</servlet-name> <url-pattern>/welcome</url-pattern> <url-pattern>/welcome. jsp</url-pattern> </servlet-mapping> <context-param> <param-name>test. Val</param-name> <param-value>654321</param-value> </context-param> </web-app>

6 -JSP implicit object: session object • The Java developer can use this object

6 -JSP implicit object: session object • The Java developer can use this object to set, get or remove attribute or to get session information and Session Tracking in JSP. • Cookies – a small text file stored on the clients machine. Cookie can be disables in the browser settings so are not always available. • URL rewriting – store session information in the URL. Works when cookies are not supported but can make bookmarking of web pages a problem because they have session specific information at the end of a URL. index. html welcome. jsp <html> <body> <form action="welcome. jsp“ > <input type ="text" name="uname“ > <input type ="submit" value="go"> </form> </body> </html> <body> second. jsp </form> </body> </html> <% %> String name = request. get. Parameter("uname"); out. print("Welcome "+name); session. set. Attribute("user", name); <a href="second. jsp"> second jsp page </a> <html> <body> <% String name = (String)session. get. Attribute("user"); out. print("Hello "+name); %> </body> </html>

6 -JSP implicit object: session object • A session object uses a key /

6 -JSP implicit object: session object • A session object uses a key / value combination to store information. • To retrieve information from a session: • session. get. Value(“msg”) • The return type of the method get. Value is Object , so you will need to typecast to get the required value. If there is not a session key with that name , null is returned. • To set a session key with a value: • session. put. Value (“msg” , val)

7 -JSP implicit object: page. Context • In JSP, page. Context is an implicit

7 -JSP implicit object: page. Context • In JSP, page. Context is an implicit object of type Page. Context class. • It can be used to set, get or remove attribute from one of the following scopes: • page, request, session, application • In JSP, page scope is the default scope index. html <html> <body> <form action="welcome. jsp“ > <input type ="text" name="uname“ > <input type ="submit" value="go"> </form> </body> </html> welcome. jsp <html> <body> <% String name=request. get. Parameter("uname"); out. print("Welcome "+name); page. Context. set. Attribute( "user", name, Page. Context. SESSION_SCOPE); <a href="second. jsp">second jsp page</a> %> </form> </body> </html> second. jsp <html> <body> <% String name=(String)page. Context. get. Attribute("user", Page. Context. SESSION_SCOPE); out. print("Hello "+name); %> </body> </html>

8 -JSP implicit object: page • In JSP, page is an implicit object of

8 -JSP implicit object: page • In JSP, page is an implicit object of type Object class. • page object -Represents the JSP page and is used to call any methods defined by the servlet class. • This object is assigned to the reference of auto generated servlet class. • It is written as: Object page=this; • For using this object, it must be cast to Servlet type. • For example: • <% (Http. Servlet) page. log("message"); %> • Since, it is of type Object it is less used because you can use this object directly in jsp. • For example: • <% this. log("message"); %>

9 -JSP implicit object: exception • In JSP, exception is an implicit object of

9 -JSP implicit object: exception • In JSP, exception is an implicit object of type java. lang. Throwable. • It can be used to print the exception. But it can only be used in error pages. • It is better to learn it after page directive. error. jsp <%@ page is. Error. Page="true" %> <html> <body> Sorry following exception occurred: <%= exception %> </body> </html>

Exception Handling in JSP • • • The exception is normally an object that

Exception Handling in JSP • • • The exception is normally an object that is thrown at runtime. Exception Handling is the process to handle the runtime errors. There may occur exception any time in your web application. So handling exceptions is a safer side for the web developer. In JSP, there are two ways to perform exception handling: • By error. Page and is. Error. Page attributes of page directive • By <error-page> element in web. xml file

JSP Error Example: using page directive • In this case, you must define and

JSP Error Example: using page directive • In this case, you must define and create a page to handle the exceptions • In pages where the exception may occur, define the error. Page attribute of page directive, as in the process. jsp page. There are 3 files: • index. jsp for input values • process. jsp for dividing the two numbers and displaying the result • error. jsp for handling the exception index. jsp <html> <body> <form action="process. jsp"> No 1: <input type="text" name="n 1" /><br/> No 1: <input type="text“ name="n 2" /><br/> <input type="submit" value="divide"/> </form> </body> </html> error. jsp <%@ page is. Error. Page="true" %> <html> <body> Sorry following an exception is occurred Exception is: <%= exception %> </body> </html> process. jsp <html> <body> <% String num 1=request. get. Parameter("n 1"); String num 2=request. get. Parameter("n 2"); int a=Integer. parse. Int(num 1); int b=Integer. parse. Int(num 2); int c=a/b; out. print("division of numbers is: "+c); %> </body> </html>

Examples: Standard Actions • Standard actions are well known tags that affect the run

Examples: Standard Actions • Standard actions are well known tags that affect the run time behavior of the JSP and the response sent back to the client. • Some commonly used tag actions types are: <jsp: use. Bean> <jsp: set. Property> <jsp: get. Property> <jsp: param> <jsp: include> <jsp: forward> <jsp: plugin>

JSP Action Tags • The action tags are used to control the flow between

JSP Action Tags • The action tags are used to control the flow between pages and to use Java Bean. JSP Action Tags Description jsp: forwards the request and response to another resource. jsp: includes another resource. jsp: use. Bean creates or locates bean object. jsp: set. Property sets the value of property in bean object. jsp: get. Property prints the value of property of the bean. jsp: plugin embeds another components such as applet. jsp: param sets the parameter value. mostly used in forward and include. jsp: fallback used to print a message if plugin is working. used in jsp: plugin.

Examples: (jsp: forward) • jsp: forward action tag • The jsp: forward action tag

Examples: (jsp: forward) • jsp: forward action tag • The jsp: forward action tag is used to forward the request to another resource it may be jsp, html or another resource. first. jsp <html> <body> <h 2>this is the first jsp page</h 2> <jsp: forward page=“second. jsp” /> </body> </html> second. jsp <html> <body> <h 2>this is the second jsp page</h 2> <% out. print("Today is: “ + java. util. Calendar. get. Instance(). get. Time()); %> </body> </html>

Examples: (jsp: include) • jsp: include action tag • It can be used to

Examples: (jsp: include) • jsp: include action tag • It can be used to include the content of another resource(jsp, html, servlet) • It includes the resource at request time, thus it is used for static as well as dynamic pages. first. jsp <html> <body> <h 2>this is the first jsp page</h 2> <jsp: include page=“second. jsp” /> <h 2>end of first page</h 2> </body> </html> second. jsp <html> <body> <h 2>this is the second jsp page</h 2> <% out. print("Today is: “ + java. util. Calendar. get. Instance(). get. Time()); %> </body> </html>

Examples: (jsp: param) • jsp: param action tag • When an include or forward

Examples: (jsp: param) • jsp: param action tag • When an include or forward element is invoked, the original request object is provided to the target page. If you wish to provide additional data to that page, you can append parameters to the request object using the jsp: param first. jsp <html> <body> <h 2>this is the first jsp page</h 2> <jsp: forward page=“second. jsp” /> <jsp: param name="name" value=“ABC" /> </body> </html> second. jsp <html> <body> <h 2>this is the second jsp page</h 2> <% out. print("Today is: “ + java. util. Calendar. get. Instance(). get. Time()); %> <%= request. get. Parameter("name") %> </body> </html>

References: • Tutorial: Working with JSPs • https: //docs. oracle. com/cd/E 11035_01/workshop 102/webapplications/workshop. JSP/tutorial

References: • Tutorial: Working with JSPs • https: //docs. oracle. com/cd/E 11035_01/workshop 102/webapplications/workshop. JSP/tutorial JSP/Tutorial. JSPEditor. Intro. html • Oracle Java. Server Pages Developer's Guide and Reference Release 8. 1. 7 • https: //docs. oracle. com/cd/A 97336_01/buslog. 102/a 83726/genlovw. htm • Java Servlet Technology • https: //docs. oracle. com/javaee/7/tutorial/servlets. htm • Java Server-side Programming Getting started with JSP by Examples • https: //www. ntu. edu. sg/home/ehchua/programming/java/JSPBy. Example. html • JSP Tutorial • https: //www. javatpoint. com/jsp-tutorial • JSP Tutorial • https: //www. tutorialspoint. com/jsp/index. htm