Idea:
Use regular HTML for most of page
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)
Example:
JSP
Thanks for ordering
<I><%= request.getParameter("title") %></I>
URL
http://host/OrderConfirmation.jsp?title=Core+Web+Programming
Result
Thanks for ordering Core Web Programming
Translation phase
Hello.jsp
Read
Request
helloServlet.java
Generate
Response
Client Server
Execute
helloServlet.class
Processing phase
Mohammed Habeeb Vulla
Template Pages
translation
<body color=#FFFFFF> <body color=#FFFFFF>
The time now is The time now is
<%= new java.util.Date() %> Tue Nov 5 16:15:11 PST 2002
</body> </body>
</html> </html>
JSP Comments
<%-- {CODE HERE} --%>
Does not show the comments on the page
Does not show the comments in page source
Can only be used outside JSP Elements
HTML Comments
<! {CODE HERE} -->
Does not show the comments on the page
Shows the comments in page source
Can only be used outside JSP Elements
Single line Comments
// {CODE HERE}
When put outside JSP Elements, shows comments on the page & source
When put inside Scriptlets/Declarations, does not show on page &
source
Can be used inside scriptlets/declarations and outside JSP Elements
11
JSP Components
13
JSP page consist of elements and templates data .These elements are described in
different elements type are:-
Directives:- JSP directives provides the page resources and their properties. Some
are as:-
1. Page directive:-Used to provide page specific properties
Eg:<%@page contentType=text/html language=java %>
Attributes are:-
1. Autoflush=true/false
2. Buffer=in KB
3. contentType=info
4. errorPage=page url
5. extends=classname
6. import=package separated by comma
7. info=infotext
8. isELIgnored=true/false
9. isErrorPage=pagenameurl
10.isThreadSafe=true/false
11.language=java
12.pageEncoding=ISO-8859-1
13.session=true/false
Mohammed Habeeb Vulla
2. Include Directives:-
The include directives tells the container to add the defined resource
content inline to the JSP page during the translation time .This tag used
to make reusability.
Ex :-
<%@ include file=header.html %>
3. Taglib Directives:-
Taglib tag is used to include external tag library in your web page.
Attributes are:-
1.Uri=url of taglibrary
2.tagDir=tag library directory
3.prefix=like object for library
Configuration files
Anything web-related
- Directories
- JavaServer Pages (JSP)
- HTML
- Css files
- JavaScript Files
- Etc.