Discuss various scopes of JSP objects briefly. Create HTML File with principal, time and rate. Then crate a JSP file that reads values from the HTML form, calculates simple interest and displays it.

  SCOPE OF JSP OBJECTS

The availability of a JSP object for use from a particular place of the application is defined as the scope of that JSP object. Every object created on a JSP page will have a scope. Object scope in JSP is segregated into four parts and they are page, request, session, and application.

a) Page Scope-page scope means, the JSP object can be accessed only from within the same page where it was created. JSP implicit objects out, exception, response, pageContext, config, and page have page scope.

//Example of JSP Page Scope

<jsp:useBean id="employee" class="EmployeeBean" scope="page" />


b) Request Scope- A JSP object created using the request scope can be accessed from any pages that serves that request. More than one page can serve a single request. Implicit object request has the request scope.

//Example of JSP Request Scope

<jsp:useBean id="employee" class="EmployeeBean" scope="request" />


c) Session Scope-session scope means, the JSP object is accessible from pages that belong to the same session from where it was created. The implicit object session has the session scope.

//Example of JSP Session Scope

<jsp:useBean id="employee" class="EmployeeBean" scope="session" />


d)Application Scope- A JSP object created using the application scope can be accessed from any page across the application. The. Implicit object application has the application scope.

//Example of JSP application Scope

<jsp: useBean id="employee" class="EmployeeBean" scope="application" /> 


2nd part

index.html

<html>

<head>

<meta charset="UTF-8">

<title>Simple Interest</title>

</head>

<body>

<h1>Simple InterestF</h1>

<form action="index.jsp">

Enter the principal : <input type="text" name="principal"><br />

<br /> Enter the time : <input type="text" name="time"><br />

<br /> Enter the rate (%) : <input type="text" name="rate"><br />

<br /> <input type="submit" value="Calculate">

</form>

</body>

</html>


index.jsp

<html>

<head>

<meta charset="UTF-8">

<title>JSP Page</title>

</head>

<body>

<%

double p = Double.parseDouble(request.getParameter("principal"));

double t = Double.parseDouble(request.getParameter("time"));

double r = Double.parseDouble(request.getParameter("rate"));

double interest = (p * t * r) / 100;

%>

<h1>

Simple Interest : <%=interest %>

</h1>

</body>

</html>

Comments

Popular posts from this blog

Suppose that a data warehouse for Big-University consists of the following four dimensions: student, course, semester, and instructor, and two measures count and avg_grade. When at the lowest conceptual level (e.g., for a given student, course, semester, and instructor combination), the avg_grade measure stores the actual course grade of the student. At higher conceptual levels, avg_grade stores the average grade for the given combination. a) Draw a snowflake schema diagram for the data warehouse. b) Starting with the base cuboid [student, course, semester, instructor], what specific OLAP operations (e.g., roll-up from semester to year) should one perform in order to list the average grade of CS courses for each BigUniversity student. c) If each dimension has five levels (including all), such as “student < major < status < university < all”, how many cuboids will this cube contain (including the base and apex cuboids)?

Suppose that a data warehouse consists of the four dimensions; date, spectator, location, and game, and the two measures, count and charge, where charge is the fee that a spectator pays when watching a game on a given date. Spectators may be students, adults, or seniors, with each category having its own charge rate. a) Draw a star schema diagram for the data b) Starting with the base cuboid [date; spectator; location; game], what specific OLAP operations should perform in order to list the total charge paid by student spectators at GM Place in 2004?

Discuss classification or taxonomy of virtualization at different levels.