150 likes | 321 Views
JAVA SERVER PAGES. -by Rubeena Memon Deepti Jain Jaya Thakar Jisha Vettuventra. What is JSP?. JSP is a technology used to generate dynamic HTML on the server side. It lets you separate the dynamic part of your pages from the static HTML.
E N D
JAVA SERVER PAGES -by Rubeena Memon Deepti Jain Jaya Thakar Jisha Vettuventra
What is JSP? • JSP is a technology used to generate dynamic HTML on the server side. • It lets you separate the dynamic part of your pages from the static HTML. • You simply write the regular HTML in the normal manner, using whatever Web-page-building tools you normally use.
(Contd.) • You then enclose the code for the dynamic parts in special tags, most of which start with "<%" and end with "%>". • Although what you write often looks more like a regular HTML file than a servlet, behind the scenes, the JSP page just gets converted to a normal servlet, with the static HTML simply being printed to the output stream associated with the servlet's service method.
Types of JSP Constructs • Aside from the regular HTML, there are three main types of JSP constructs that you embed in a page: . • Scripting elements :They let you specify Java code that will become part of the resultant servlet. • Directives :lets you control the overall structure of the servlet.
Steps of JSP Requests • Client Requests a JSP Page. • The JSP engine compiles the JSP into a servlet • The generated servlet is compiled and loaded. • The compiled servlet services the request and sends a response back to the client.
(Contd.) • Actions let you specify existing components that should be used, and otherwise control the behavior of the JSP engine
Syntax Summary • JSP Expression <%= expression %> • JSP scriptlet <% code %> • JSP Declaration <% ! code %> • JSP page Directive <%@ page att=“val” %> • JSP include Directive<%@ include file =“url” %> • JSP Comment <% -- comment --%>
(Contd.) • The jsp:include Action <jsp:include page="relative URL flush="true"/> • The jsp:useBean Action <jsp:useBean att=val*/> or <jsp:useBean att=val*/> • The jsp:setProperty Action <jsp:setProperty att=val*/>
(Contd.) • The jsp:getProperty Action <jsp:getProperty name=“idName”> • The jsp:forward Action <jsp:forward page="relative URL"/>
Advantages of JSP • vs. ASP: ASP is a similar technology from Microsoft. In JSP, dynamic part is written in Java, not Visual Basic or other MS-specific language, so it is more powerful and easier to use. Second, it is portable to other operating systems and non-Microsoft Web servers.
Vs. Servlets • JSP doesn't give you anything that you couldn't in principle do with a servlet. But it is more convenient to write regular HTML than to have a zillion println statements that generate the HTML. Plus, by separating the look from the content you can put different people on different tasks.
Vs. Javascript • JavaScript can generate HTML dynamically on the client. It only handles situations where the dynamic information is based on the client's environment. Since it runs on the client. JavaScript can't access server-side resources like databases, catalogs, pricing information, and the like.
Project Overview • Aim: Generating students mess bills. • Interfaces: • Student Interface : View Mess Bill • View Balance in Bank • After Authentication , • Mess Manager’s Interface : • Compute Bills
Mess Manager’s Interface(contd.) • Display Bills (With or Without Details) • Update Bills • Record Expenditure • Display Expenditure • Display Fines