0% found this document useful (0 votes)
161 views

Java Server Pages (JSP)

JSP (Java Server Pages) is a technology that enables developers to rapidly create dynamic web pages that leverage existing Java code and HTML. JSP pages combine HTML tags and Java code to generate servlets. This simplifies web development by allowing developers to focus on presentation logic in JSP files rather than dealing with low-level servlet APIs. JSP pages are platform independent as they are built on Java.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
161 views

Java Server Pages (JSP)

JSP (Java Server Pages) is a technology that enables developers to rapidly create dynamic web pages that leverage existing Java code and HTML. JSP pages combine HTML tags and Java code to generate servlets. This simplifies web development by allowing developers to focus on presentation logic in JSP files rather than dealing with low-level servlet APIs. JSP pages are platform independent as they are built on Java.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

J AVA S ERVER PAGES (JSP)

I NTROCDUCTION

TO JSP

Like Servlets, JSP is also a specification. JSP technology enables Web developers and designers to rapidly develop and easily maintain, information-rich, dynamic Web pages that leverage existing business systems. As part of the Java technology family, JSP technology enables rapid development of Webbased applications that are platform independent.

T HE N EED
With servlets, it is easy to

FOR

JSP

Read form data


Read HTTP request headers Set HTTP status codes and response headers

Use cookies and session tracking


Share data among servlets Remember data between requests

Get fun, high-paying jobs


But, it sure is a pain to Use those println()statements to generate HTML Maintain that HTML

T HE JSP F RAMEWORK

Use regular HTML for most of the pages

Mark servlet code with special tags


Entire JSP page gets translated into a servlet (once), and servlet is what actually gets invoked (for each request) The Java Server Pages technology combine with Java code and HTML tags in the same document to produce a JSP file.

W HAT

IS JSP ?

W EB A PPLICATION S ERVER A RCHITECTURE

A DVANTAGE OF JSP :

Jsp is simple , capable of creating complex web application . Jsp leverages the poer of Java. JSP simplifies web development (JSP also includes numerous implicit object that the web development process . These implicit objects allow you to retrieve and process data submitted in form, track users, and send output to a web browser. Jsp is not limited to a particular platform. Jsp is an integral part of J2EE.

A DVANTAGES OF JSP OVER C OMPETING T ECHNOLOGIES

J SP

LIFE CYCLE

EXAMPLE

S HOW CURRENT SYSTEM DATE


<%@ page import=java.util.* %> <html> <body> <h3> Current Date is:<%= new Date()%> </h3> </body> </html> Just Compare it with servlet Code it is too much easy .

B ESIDES HTML, A JSP MAY CONTAIN THE FOLLOWING ELEMENTS .

S CRIPTING E LEMENTS

S CRIPTING E LEMENTS

S CRIPTING E LEMENTS

I MPLICIT

OBJECTS

I MPLICIT

OBJECTS

MVC

I MPLICIT

OBJECTS

JSP D IRECTIVES

JSP directives are used to convey special processing information about the page to JSP container. It affects the overall structure of the servlet that results from the JSP page. It enables programmer to: Specify page settings To Include content from other resources To specify custom-tag libraries Format

<%@ directive {attribute=val}* %> In JSP, there are three types of directives: page, include & taglib. The formats of using these are:

page: <%@ page {attribute=val}* %> include: <%@ include {attribute=val}* %> taglib: <%@ taglib {attribute=val}* %>

JSP

PAGE

D IRECTIVE

Give high level information about servlet that will result from JSP page. It can be used anywhere in the document. It can control Which classes are imported

What class the servlet extends


What MIME type is generated How multithreading is handled If the participates in session Which page handles unexpected errors etc.

JSP

PAGE

D IRECTIVE

JSP

INCLUDE

D IRECTIVE

You might also like