Download presentation
Presentation is loading. Please wait.
Published byJocelyn Charles Modified over 9 years ago
1
Overview of JSP Technology
2
The need of JSP With servlets, it is easy to – 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 – set up custom code to handle missing and malformed data But, Servlets are not so good at presentation – It is hard to write and maintain the HTML using println() statements. – The HTML is inaccessible to non-Java developers – You cannot use standard HTML tools
3
What is JSP? Java Server Pages(JSP) technology is used to create dynamic web pages and which enables you to mix regular static HTML with dynamically generated content. – Use regular HTML for most of page – Enclose servlet code( for dynamic part) with special tags – Entire JSP page gets translated into a servlet (once), and servlet is what actually gets invoked (for each request) Example: Order Confirmation Order Confirmation Thanks for ordering !
5
Benefits of JSP JSP provides the following benefits over servlets alone. JSP makes it easier to: – Write HTML – Read and maintain the HTML JSP makes it possible to: – Use standard HTML tools such as DreamWeaver - Divide up your development team. -Java developers can concentrate on dynamic code and web developers can concentrate on the presentation layer. JSP encourages you to – Separate the (Java) code that creates the content from the (HTML) code that presents it
6
Advantages of JSP Over Competing Technologies Versus.NET and Active Server Pages – Better language for dynamic part – Portable to multiple servers and operating systems - Since the dynamic part of Jsp written in java, Jsp is more powerful and suited to complex applications that require reusable components Versus PHP – dynamic part of JSP is written in Java, which has an extensive API for networking, database access, distributed objects, whereas PHP requires learning an entirely new, less widely used language – JSP more widely supported by tool Versus Velocity or WebMacro – Standardization, portability, Tremendous industry support
7
- JSP specifications define a standard directory structure for web applications and provide standard files for deploying web application. Versus client-side JavaScript (in browser) – Javascript capabilities mostly do not overlap with JSP(which runs only on the server) -JSP pages include script tags for JavaScript -Java Script is not a competing technology, it is a complementary one Versus pure servlets – More convenient to create HTML – Can use standard tools (e.g., DreamWeaver) – Easy to maintain because we can separate business logic with presentation logic – JSP programmers still need to know servlets for 4 reasons
8
1. JSP pages get translated into servlets. You can’t understand how JSP works without understanding servlets. 2. JSP consists of static HTML, special-purpose JSP tags, and Java code(i.e Servlet code). You can’t write that code if you don’t understand servlet programming. 3. Some tasks are better accomplished by servlets than by JSP. JSP is good at generating pages that consist of large sections of fairly well structured HTML or other character data. Servlets are better for generating binary data, and performing tasks (such as redirection) that involve little or no output. 4. Some tasks are better accomplished by a combination of servlets and JSP than by either servlets or JSP alone.
9
Basic Syntax HTML Text Description: HTML content to be passed unchanged to the client Example: Blah HTML Comments Description: HTML comment that is sent to the client but not displayed by the browser Example: Template Text Description: Text sent unchanged to the client. HTML text and HTML comments are just special cases of this. Example: Anything other than the syntax of the following subsections
10
JSP Comment Description: Developer comment that is not sent to the client Example: JSP Expression Description: Expression that is evaluated and sent to the client each time the page is requested Example: JSP Scriptlet Description: Statement or statements that are executed each time the page is requested Example:
11
JSP Declaration Description: Field or method that becomes part of class definition when page is translated into a servlet Examples: JSP Directive Description: High-level information about the structure of the servlet code (page),code that is included at page- translation time (include), or customtag libraries used (taglib) Example:
12
JSP Action Description: Action that takes place when the page is requested Example:... JSP Expression Language Element Description: Shorthand JSP expression Example: ${ EL Expression } Custom Tag (Custom Action) Description: Invocation of custom tag Example: Body
13
Escaped Template Text Description: Text that would otherwise be interpreted specially. Slash is removed and remaining text is sent to the client Examples: <\% %\>
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.