Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Â
Jsp presentation
1. WHAT IS JSP???
JSP is a java based technology used to simplify the development of
dynamic web pages. JSP is used to separate dynamic content of web page
from its content with the help of HTML and JSP tags. Current version is 2.1.
9. WHAT ARE JSP ELEMENTS?????
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”
10. WHAT ARE JSP ELEMENTS?????
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.
Eg :-
<%@ 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”
11. HOW MANY SCRIPTING ELEMENTS USED IN
JSP?????
• 1. <%! This is a declaration %>
• 2. <% this is a scriptlet %>
• 3. <% = this is an expression %>
12. NOW I AM DESCRIBING ACTION ELEMENTS IN
JSP ?????????
13. DESCRIBING ACTION ELEMENTS IN JSP
?????????
Action elements are certain directives that are given
to the container perform certain task during the
execution of a JSP page.
14. DESCRIBING ACTION ELEMENTS IN JSP ?????????
1. <JSP:useBean>:-
The useBean tag is used to create instance for specified java bean for JSP
page.
Attributes of this tag:-
Id => what the object name you want to specifiy for this bean.
Scope => whats the scope of bean object page,request,session or
application.
Class => case sensitive name of bean class
beanName => a valid bean name no include the bean classname
type => optional attribute java class has been defined.
15. DESCRIBING ACTION ELEMENTS IN JSP ?????????
• 1. <JSP:getProperty> :-
• this action used to access the defines property to bean object.But it is
important to declare bean object using useBean tag.
• Attributes are:-
• 1. name :- The name of object where to retrieve object properties.
• 2. property: - Name of property to get.
• Eg:-
• <jsp:getProperty name=”beanname”property=”propertyname”>
16. DESCRIBING ACTION ELEMENTS IN JSP ?????????
• 1. <JSP:getProperty> :-
this action used to access the defines property to bean object.But it
is important to declare bean object using useBean tag.
Attributes are:-
1. name :- The name of object where to retrieve object properties.
2. property: - Name of property to get.
Eg:-
<jsp:getProperty
name=”beanname”property=”propertyname”>
17. DESCRIBING ACTION ELEMENTS IN JSP ?????????
. <JSP:setProperty> :-
This action element is used to set the property of bean object specified by usebean tag.
Attributes are:-
1.Name :- name of bean which have to specify value
2.Property:-
name of property value to be set we can also use * to specify all the property of bean.but in this
case you have to specify the name of components as bean property.
3.Param:- The name of the request parameter whose value you want to give to a bean
property.this name basically come from web form.
4.Value:- the value to be assign to this property.
Eg:-
<jsp:setProperty name=”beanname” property=”propertyname” value=”tobeset” >
=”propertyname”>
18. NOW UNDERSTAND THIS USING EXAMPLE
We are creating a login screen with java bean which
check the username and password and return the
result according to input
19. INDEX.JSP
<%--
DOCUMENT : INDEX
CREATED ON : APR 2, 2012, 12:23:12 PM
AUTHOR : BARDHAN
--%>
<%@PAGE CONTENTTYPE="TEXT/HTML" PAGEENCODING="UTF-8"%>
<!DOCTYPE HTML>
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=UTF-8">
<TITLE>JSP PAGE</TITLE>
</HEAD>
<BODY>
<FORM ACTION="CHECK.JSP" METHOD="POST">
ENTER NAME <INPUT TYPE="TEXT" NAME="NAME" /><BR>
ENTER PASSWORD <INPUT TYPE="PASSWORD" NAME="PASSWORD" />
<BR/>
<INPUT TYPE="SUBMIT" VALUE="LOGIN" />
<INPUT TYPE="RESET" VALUE="RESET" />
</FORM>
</BODY>
</HTML>
20. CHECK.JSP PAGE:-
<%--
DOCUMENT : CHECK
CREATED ON : APR 2, 2012, 12:29:55 PM
AUTHOR : BARDHAN
--%>
<%@PAGE CONTENTTYPE="TEXT/HTML" PAGEENCODING="UTF-8"%>
<!DOCTYPE HTML>
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=UTF-8">
<TITLE>JSP PAGE</TITLE>
</HEAD>
<BODY>
<JSP:USEBEAN ID="LOGIN" CLASS="BEANS.LOGIN" SCOPE="PAGE">
<JSP:SETPROPERTY NAME="LOGIN" PROPERTY="*" />
</JSP:USEBEAN>
YOUR NAME:<JSP:GETPROPERTY NAME="LOGIN" PROPERTY="NAME" />
<BR>
YOUR PASSWORD IS:<JSP:GETPROPERTY NAME="LOGIN" PROPERTY="PASSWORD" />
<%BOOLEAN BA=LOGIN.GETRESULT();
IF(BA)
{
RESPONSE.SENDREDIRECT("WELCOME.JSP");
}
ELSE{
OUT.PRINTLN("THIS IS NOT RIGHT USERNAME OR PASSWORD");
}
%>
</BODY>
</HTML>
21. •
• Bean.login bean:- public void setName(String name) {
/* this.name = name;
* To change this template, choose }
Tools | Templates public String getPassword() {
* and open the template in the editor. return password;
*/ }
package beans;
public void setPassword(String
password) {
/** this.password = password;
* }
* @author BARDHAN public boolean getResult()
{
*/
public class login if(this.name.equals("sanju")&&password.eq
{ uals("123"))
private String name; {
result=true;
private String password;
private boolean result; }
else
{
public String getName() { result=false;
return name; }
} return result;
}
}
22. DESCRIBING ACTION ELEMENTS IN JSP ?????????
4. .<JSP:param>:-
This action element is used to pass the parameter to other action
elements. For example
<jsp:forward page=”hello.jsp”>
<jsp:param name=”id” value=”12” />
</jsp:forward>
23. DESCRIBING ACTION ELEMENTS IN JSP ?????????
• 5.<jsp:include> :-
• This action element is used to include any jsp file in your web page.
• <jsp:include page=”header.jsp” flush=”true|false” />
• 6.<jsp:forward> :-
• Used to forward request control to next page .For example
• <jsp:forward page=”next.jsp” ></jsp:forward>
•
• 7.<jsp:expression>:- work like expression script
• 8.<jsp:scriptlet> :- work like as script element
• 9.<jsp:declaration> :-work as declaration element
24. DESCRIBING THE JSP IMPLICIT
OBJECTS…………………….
JSP Implicit objects are described as follows
1. Application :- Used as Servlet Context object in servlets
2. Config:- Used as ServletConfig object in servlets
3. Out :- JSPWriter object to print any thing on jsp page
4. Page:- work like as Object class object
5. pageContext:- PageConext for JSP page
6. request: work like as ServletRequest object
7. response:- work like as ServletResponse Object in Servlets
8. session :- like as httpSession.