Chapter 4 - HTML 5 and JSP
Chapter 4 - HTML 5 and JSP
Mettu University
Department of Information Technology
3rd Year
Advanced Programming – Chapter 5
HTML
HTML Introduction
• HTML (Hyper Text Markup Language) is a markup language used to create webpages.
• Several webpages combine to form a website
• HTML uses set of built-in tags, enclosed in angular brackets
• HTML code will have the file extension as .html
• HTML used to write user interface (UI) fro web development programs
• HTML provides it means to create a structured document such as headings,
paragraphs, lists, links, quotes, and other so many items.
• Support images and objects (audio and video) to be embedded and create a
interactive WebPages.
• Scripts languages such as JavaScript, VB script which are allow to load that affect to
create a dynamic user interactive WebPages.
HTML Tags
• HTML tags keywords are surrounding in Opening Tag <html>
and Closing Tag</html>.
• HTML tags is pairs like <body> and </body>. It's
container tags.
• Some HTML tags is not pairs in Opening and Closing like
<br />, <hr />. It's empty tags.
• All tags are write in Lower Alphabetical and empty tags
always write in closing Tag type like <br />.
HTML Head Section
• HTML <head> tag is a Container Tag. All Header element
contains like general information about page, meta-
information, style sheet URL and document type
information.
• HTML <head> tag inside elements does not display in body
part on web browser.
• HTML <head> tag inside Elements is <!doctype>, <base>,
<link>, <meta>, <title>, <style> and <script>.
HTML Body Section
• HTML body section is a main contain section of web page
all contain that will be seen when the user loads the
webpage.
• HTML body section supported all the contains such as
text, hyperlinks, images, Special Character, lists,
tables, frames, forms etc.
• It's most powerful section and important section to
display web page.
HTML BASIC TAGS
HTML Paragraph Tag
• Defines a paragraph into web document. HTML paragraph
define using <p> tag.
Example-Code:
<body>
<p> This is first Paragraphs </p>
<p> This is Second Paragraphs </p>
</body>
HTML Comment Tag
• Defines the Comments <!-- Your Comment --> tag.
• Example-Code:
<body>
<!--Image File-->
<img src="../../jix/w2t.png" width="380" height="70" />
</body>
HTML IMAGE Tag
• To display Images into web document. HTML Images are
define inside the <img> tag.
• Example-Code:
<body>
<img src="../../jix/w2t.png" width="380" height="70" />
</body>
HTML LINK Tag
<body>
<h1> Heading Tag </h1>
<h2> Heading Tag </h2>
<h5> Heading Tag </h5>
<h6> Heading Tag </h6>
</body>
HTML ATTRIBUTES
• HTML tags contain have one or more attributes are
support.
• HTML Attributes are added in tag to provide the more
additional information about how the tag should be
appear or behavior.
• HTML Attributes are always specified in the start tag.
• HTML Attributes consist on name/value pairs
like: i.e. name="value" and separated by an equals (=)
sign.
• Attribute values always be enclosed in double/single
quotes.
• Double quotes are the most common use, but single quotes
are also allowed.
HTML ATTRIBUTES (Continued)
<head>
<title> HTML Attributes Example </title>
<style type="text/css"> #second { color:#FF9966; } </style> </head>
<body>
<p style="background-color:red">First Attributes</p>
<p id="second">Second Attributes</p>
<p>Third Attributes</p>
<p><abbr title="Cascading Style Sheet">CSS</abbr></p> </body>
HTML Text Formatting TAGS
HTML Ordered List
• HTML <ol> tag define ordered list(list of Ordered items). HTML <ol> tag
is a Container tag.
• <ol> Tag Attributes
HTML <ol> tag specified Order list display list of item and
its attribute help to change the type of order list.
• <li> Tag Attributes
<li> tag specified list items and its attribute help to change
the type of order list.
Example: <ol type="I" value="1">
<li>Upper Roman numeral</li>
<li>Upper Roman numeral</li>
</ol>
HTML Unordered List
• HTML <ul> tag define Unordered List(list of Unordered items).
HTML <ul> tag is a Container tag.
• It is use to display list of item with Bulleted style.
• <ul> Tag Attributes
HTML <ul> tag specified Unordered list display list of
item and its attribute help to change the different type of
list.
• <li> Tag Attributes
HTML <li> tag specified list items and its attribute
helps to change the unorder of the list.
• Example:
<ul type="disk" >
<li>Disk Bullet</li>
<li>Disk Bullet</li>
</ul>
HTML Definition List
• Definition and Usage
• Definition list is use for create glossary list. Definition list
are stars with <dl> tag and close with </dl> tag.
• <dl> tag have two tag <dt> and <dd> defined inside tag.
• <dl> tag is a empty tag. Its use to define definition list. It
does not have any attributes.
• <dt> tag is a empty tag. Its use to define definition team. It
does not have any attributes.
• <dd> tag is a empty tag. Its use to define definition define. It
does not have any attributes.
<dl>
<dt>URL
<dd>Universal Resource Locator
<dt>W3C
<dd>World Wide Web Consortium
<dt>PNG
<dd>Portable Network Graphics
</dl>
ADVANCED HTML TAGS
HTML Table
• The best way to split a page into different sections is to
use HTML <table> Tag.
• HTML Table section is top of (start with) <table> tag, and
closed it right down at the </table> tag. Everything in
between those two tags is inside the table, as you can see in
following screenshot.
• Look at the following figure. <table> tag inside you need two
more tag first is <tr> tag, which stands for table row. It is
closed with the </tr> tag. And another one is <td> tag, which
stands for table data.
• Every time you add a <tr> tag, when table will gain an extra
row.
• HTML <td> tag stands for table data (also say table column),
and it places one cell in your table row.
• HTML table you also merge two or more column or two or more
row merge using respectively colspan or rowspan attributes.
HTML Table (Continued)
HTML Table (Continued)
HTML form
• HTML Forms is most important future in HTML.
• HTML Forms use to get a users information. its also say
user is interactive with it.
• HTML Forms is a information tools to get information
from the web surfer, such as: name, email address,
address, phone number etc.
HTML Form (Continued)
<input> Tag
HTML Form (Continued)
HTML 5
What is HTML5?
• HTML5 is the new standard for HTML.
<!DOCTYPE html>
HTML5 NEW ELEMENTS
HTML5 Input Types
HTML5 has several new input types for forms. These new features
allow better input control and validation.
• color
• Date
• datetime
• datetime-local
• email
• month
• number
• range
• search
• tel
• time
• url
• week
HTML5 Semantic Elements
• HTML5 offers new semantic elements to clearly define
different parts of a web page:
• <header>
• <nav>
• <section>
• <article>
• <aside>
• <figcaption>
• <figure>
• <footer>
JSP (Java Server Pages)
Bucket list
• Introduction to JSP.
• What is JSP?
• Why JSP?
• JSP Life Cycle
• Basic Tags in JSP
• JSP – Actions
• Directives and its Types
• Page Context and its Methods
• JSTL Tags
Introduction to JSP
• Java Server Pages (JSP) is a server-side programming
technology that enables the creation of dynamic,
platform-independent method for building Web-based
applications.
Declaration Tag
• Declaration tag is a block of Java code for declaring class wide variables,
methods and classes. Whatever placed inside these tags gets initialized
during JSP initialization phase and has class scope.
• Syntax: <%! Declaration %>
JSP - Actions
<jsp:include> Action Tag
• To include the file during the request processing (dynamic)
• Syntax : <jsp:include page="page URL" flush="Boolean Value" />
Page
Directives
Include taglib
Page Directive
• The page directive is used to provide instructions to
the container that pertain to the current JSP page. You
may code page directives anywhere in your JSP page. By
convention, page directives are coded at the top of the
JSP page.
• Syntax:
<%@ page attribute="value" %>
• Example:
<%@ page import="java.util.Date" %>
Include directive
• The include directive is used to includes a file during
the translation phase.
• This directive tells the container to merge the content
of other external files with the current JSP during the
translation phase.
• We can code include directives anywhere in your JSP
page.
• Syntax:
<%@ include file="relative url" >
• Example:
<jsp:include page=“header.jsp" />
Taglib directive
• The taglib directive declares that your JSP page uses a
set of custom tags, identifies the location of the
library, and provides a means for identifying the custom
tags in your JSP page.
• Syntax:
<%@ taglib uri="uri" prefix="prefixOfTag" >
• Example:
• Advantage of JSTL
– Fast Developement JSTL provides many tags that simplifies
the JSP.
– Code Reusability We can use the JSTL tags in various pages.
– No need to use scriptlet tag It avoids the use of scriptlet
tag.
Types of tags in JSTL
sql tags The JSTL sql tags provide SQL support. The url for the sql tags
is http://java.sun.com/jsp/jstl/sqland prefix is sql.
xml tags The xml sql tags provide flow control, transformation etc. The url for the xml
tags ishttp://java.sun.com/jsp/jstl/xml and prefix is x.
Formatting tags The JSTL formatting tags are used to format and display text, the date, the
time, and numbers for internationalized Web sites. The url for the functions
tags <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
functions tags The functions tags provide support for string manipulation and string length.
The url for the functions tags is http://java.sun.com/jsp/jstl/functions and
prefix is fn.
JSTL - Core tags
• <c:out >
• <c:set >
• <c:remove >
• <c:catch>
• <c:if>
• <c:choose>
• <c:when>
• <c:otherwise >
• <c:import>
• <c:forEach >
• <c:forTokens>
• <c:param>
• <c:redirect >
• <c:url>
THANK YOU