SlideShare a Scribd company logo
Continued….
 OGNL is an expression language that is used to
retrieve values from stack.
 Normally when actions are called, request
parameters, values passed to action, the action bean
instance, all are pushed into a stack called as “Value
Stack”.
 The value stack holds values for the action.
 OGNL is used in views to retrieve values from this
stack.
 The best thing about struts 2 is OGNL can also be used in the
struts.xml file.
 The following code specifies how OGNL can be used to specify
values in the value stack:
<action name=“ShowMail” class=“com.example.ShowMails”>
<result>/mails/showMails.jsp?username=${username}</result>
</action>
 This means when the result page would be rendered the url
would be appended with the value retrieved by the username
property of the present action class i.e. ShowMails.
 Apart from retrieving data from action class. OGNL helps retrieve data from the
following objects:
 #application
 #session
 #request
 #attr
 #parameters
 For example the following code would fetch the value username from the user
object in session.
<s:property value=“#session.user.username”/>
 This in essence is equivalent to:
<% User user=session.getAttribute(“user”);
Out.println(user.getUsername());
%>
 Functionality for creating views in JSP is provided by Struts
in the form of tag library.
 The struts tag library is included in the following way in
JSP pages that contain struts-tags:
<%@taglib uri=“/struts-tags” prefix=“s”%>
 The TLD file for the struts tags is present in the jar files of
the struts libraries.
 Struts tags fall into these two categories:
 Generic Tags: Generic tags control the execution flow when pages are
rendered. They are also used to extract data.
 UI Tags: UI Tags are used to create user interface elements like form
field etc.
 Apart from the tag library, Struts 2 also provides
OGNL(Object Graph Navigation Language), an intuitive way
to retrieve values and embed them in views from the
session, action beans etc.
 Generic Tags are of two types:
 Data Tags: They are used to retrieve data from objects
and display them in web pages.
 Control Tags: Control tags are used to emulate loops
and decision making constructs like while, for, for and
if…else.
 The action tag: This tag is used to invoke some other action
from the present page, where it is embedded. Its beneficial
when you want some functionality to be invoked in the JSP
page without using scriptlets.
 Syntax
<s:action name=“AuthenticateAction” executeResult=“true”/>
Attribute Meaning
Id For referencing the element
Name The name of the action that is being called
executeResult Whether the result of the action should be displayed
or not
Namespace Namespace of the action that has to be called
Flush Whether the writer should be flushed after execution
of this tag
var Reference name of the action bean so that it can be
used later in the page
ignoreContextParams Whether the request parameters are supposed to be
included while calling the action
 The property tag: The property tag is used to
inject values contained in objects into the JSP
page. These values are fetched from the value
stack (The value stack is a stack that contains
all the objects that the action is dealing with,
while the action‟s methods are called).
 Syntax:
<s:property value=“user.username”/>
 Output:
Hello Chandrakant
Attribute Meaning
id For referencing the element
value The value to be displayed
default If the attribute is not started then
the default value that would
appear in its place.
escape Whether HTML would be escaped.
 The bean tag: The bean tag is used to instantiate a class that
conforms to the java bean specification. It‟s similar to jsp‟s
useBean tag.
 Syntax
<s:bean name=“com.example.Employee” var=“emp”/>
Attribute Meaning
id For referencing the element
name Name of the class whose instance
is supposed to be created.
var Name of the reference for the bean
object that can be used later on.
 The set tag: This tag is used to set some data into a bean instance
or into one of the following:
 Session scope
 Application scope
 Request scope
 Page scope
 Action(by default)
 Syntax
<s:set name=“firstName” scope=“session” value=“user.firstName”/>
Attribute Meaning
Id For referencing the element
name Reference name of the variable
that is set in the specified scope.
value The value that is set
scope The scope in which the value
should be placed
 The include tag: This tag is used to include certain JSP page‟s
or Servlet‟s result into the present page. Its functionality
similar to the jsp include action.
 Syntax
 <s:include value=“listAllDepartments.jsp”/>
Attribute Meaning
value The name of the JSP page or the
servlet‟s alias that has to be
included in the present page.
 The url tag: The url tag is used to
 Render absolute or relative URLs
 Handle parameters
 Encodes URL‟s so that it can be used in browsers where cookies are
disabled.
 Syntax
<s:url action=“Login.action” var=“loginURL”>
<s:param name=“useType” value=“Admin”/>
</s:url>
Attribute Meaning
Id For referencing the element
value The base url
action Name of the target Action
namespace Namespace of the action that has to be called
encode Used to add session id to the url
var Reference name of the url so that it can be used
later in the page
includeParams/include To include the parameters or the context
method The method of the action that has to be called
Method The method of the action that has to be used
Scheme The protocol(http/https)
 The param tag: This tag is used for providing parameters to
other tags.
 Syntax:
<s:param name=“color”>#ff0000</s:param>
Attribute Meaning
id For referencing the element
name The name of the parameters to be
set
value Value that has to be set for the
parameter
 Control tags used for referencing emulating control
structures like loops and decision constructs.
 There are basically two control tags
 Iterator tag
 If, elseif and else tags
 The iterator tag is used for iterating through the collections of objects.
The collections can be one of the following types:
 Collections
 Maps
 Enumeration
 Iterators
 Arrays
 Syntax:
<s:iterator status=“num” value=“{1, 2, 3, 4, 5}”>
<s:property value=“top”/>
</s:iterator>
Attribute Meaning
Id For referencing the element
Value The object to be iterated over
Status It is used to mention whether an
instance of the IteratorStatus
should be pushed into the stack in
each iteration.
 The if, elseif and else tags: These tags are used to emulate an if…else
if…else construct.
 Syntax:
<s:if test=“%{#userRole==„Admin‟}”/>
<!–- Do something here.. -->
</s:if>
<s:elseif test=“%{#userRole==„HR‟}”/>
<!–- Something else--> -- >
<s:else>
<!– Do what should be done if all fails. -->
</s:else>
Attribute Meaning
Id For referencing the element
Test The expression of that needs to be
tested to determine if body of the
tag would be executed.
 UI Tags are used to generate form elements or display data in simple are
reusable format.
 Tags, themes and templates combine together to produce flexible,
feature-rich and extensible UI components.
 The struts UI tags are backed by templates that do the actual work.
 Templates group together to form themes. The various themes are:
 simple
 ajax
 Xhtml
 css_xhtml
 UI Tags are used to create form elements.
 The following are few Struts UI Tags:
◦ s:form, s:textfield, s:password, s:hidden, s:textarea, s:submit,
s:file, s:checkbox, s:select, s:radio, s:reset
 Views are usually specified in the struts.xml as results of actions. For
instance:
<action name=“LoginScreen”>
<result>login.jsp</result
</action>
 The result tag has a type attribute that can take the following values:
 Redirect – This is specified as the value of type if we want the controller to redirect
to a different page on the event of an action‟s result. This can redirect to another
JSP page or servlet.
 redirectAction – This is similar to redirect, however with redirectAction, the name
of some other action can be specified.
Struts 2
 The struts2 validation framework is one of the most comprehensive
ones that struts 2 core is composed of.
 Struts 2 provides support for both server-side and client-side
validation.
 A lot of predefined validators and ability to create and plug in
custom validators adds to the validation prowess of the framework.
 Struts provides both declarative and programmatic validation
techniques.
 Programmatic validation is achieved in Action classes by implementing the
Validateable interface in the action class.
 This interface has the void validate() method, which needs to be overridden.
 Validation code is put in this function.
 In case the Action class needs to report the validation errors, then it needs to
implement the ValidationAware interface that has methods for error logging.
These two interfaces are implemented in the ActionSupport class. So
extending ActionSupport automatically makes the action class possess validation
capabilities. All that needs to be done is overriding of the validate() method and
reporting of the validation errors.
 Usually programmatic validation is used in complex validation scenarios.
 In case things like pattern of input data, input data length, data
type(number or string or email address) have to be validated, declarative
validation is a better choice.
 Declarative validation is done in xml files that are present in the same
directory as the Action class.
 These files are named in this manner
 <Action class name>-validation.xml
 For instance if the name of the Action class is Employee the
validation.xml file would be:
 Employee-validation.xml
<validators>
<field name=“count”>
<field-validator type=“int” short-circuit=“true”>
<param name=“min”>1</param>
<param name=“max”>100</param>
<message key=“invalid.count”>
value must be between ${min} and ${max}
</message>
</field-validator>
</field>
<field name=“name”>
…
</field>
…
…
</validators>
 Inside the validation xml file there can be multiple <field></field>
entries, each corresponding to a property of the action class.
 The <field> element may be contain one or more <field-validator>
entries. Each of these field-validator represents a validation rule.
 The type attribute of the <field-validator< tag specifies what kind of
validation is required.
 The short-circuit attribute(if set to true) would prevent the rest of the
validators from validating.
 Param tags can be used to specify validation parameters.
 Validators can either act upon single fields or can
act upon the whole action context.
 In case a validator has to act upon the whole action
context then instead of <field-validator>, the
<validator> tag is used.
 <validator> has a higher precedence over <field-
validator>
Validator type Parameters
required fieldName
requiredString fieldName, trim
stringLength fieldName, maxLength, minLength, trim
Int fieldName, min, max
Double fieldName, maxInclusive, minExclusive, maxExclusive
Date fieldName, max, min
Expression Expression
fieldExpression Expression
Email fieldName
url fieldName
Conversion fieldName
Regex fieldName, expression, caseSensitive, trim
 In case errors are encountered during validation(programmatic or
declarative), the result of the action automatically becomes input.
 Therefore to handle result of type input, there should be an appropriate
element in struts.xml.
 For example:
<action name=“SaveEmployeeDetails” class=“com.example.Employee”>
<result name=“input”>employeeForm.jsp</result>
<result name=“success”>saveSuccess.jsp</result>
</action>
Ad

More Related Content

What's hot (20)

Struts2 - 101
Struts2 - 101Struts2 - 101
Struts2 - 101
Munish Gupta
 
Struts2.x
Struts2.xStruts2.x
Struts2.x
Sandeep Rawat
 
Struts
StrutsStruts
Struts
Rajkumar Singh
 
Jpa 2.1 Application Development
Jpa 2.1 Application DevelopmentJpa 2.1 Application Development
Jpa 2.1 Application Development
ThirupathiReddy Vajjala
 
JPA Best Practices
JPA Best PracticesJPA Best Practices
JPA Best Practices
Carol McDonald
 
JPA 2.1 performance tuning tips
JPA 2.1 performance tuning tipsJPA 2.1 performance tuning tips
JPA 2.1 performance tuning tips
osa_ora
 
Entity Persistence with JPA
Entity Persistence with JPAEntity Persistence with JPA
Entity Persistence with JPA
Subin Sugunan
 
Spring annotation
Spring annotationSpring annotation
Spring annotation
Rajiv Srivastava
 
Annotations
AnnotationsAnnotations
Annotations
Knoldus Inc.
 
Hibernate complete Training
Hibernate complete TrainingHibernate complete Training
Hibernate complete Training
sourabh aggarwal
 
Advance Java
Advance JavaAdvance Java
Advance Java
Vidyacenter
 
SAP Testing Training
SAP Testing TrainingSAP Testing Training
SAP Testing Training
VGlobal Govi
 
Hibernate in Nutshell
Hibernate in NutshellHibernate in Nutshell
Hibernate in Nutshell
Onkar Deshpande
 
Java Annotations
Java AnnotationsJava Annotations
Java Annotations
Serhii Kartashov
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
ecosio GmbH
 
Java Annotation
Java AnnotationJava Annotation
Java Annotation
karthik.tech123
 
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
Jorge Hidalgo
 
Introduction to JPA (JPA version 2.0)
Introduction to JPA (JPA version 2.0)Introduction to JPA (JPA version 2.0)
Introduction to JPA (JPA version 2.0)
ejlp12
 
hibernate with JPA
hibernate with JPAhibernate with JPA
hibernate with JPA
Mohammad Faizan
 
Session 38 - Core Java (New Features) - Part 1
Session 38 - Core Java (New Features) - Part 1Session 38 - Core Java (New Features) - Part 1
Session 38 - Core Java (New Features) - Part 1
PawanMM
 
JPA 2.1 performance tuning tips
JPA 2.1 performance tuning tipsJPA 2.1 performance tuning tips
JPA 2.1 performance tuning tips
osa_ora
 
Entity Persistence with JPA
Entity Persistence with JPAEntity Persistence with JPA
Entity Persistence with JPA
Subin Sugunan
 
Hibernate complete Training
Hibernate complete TrainingHibernate complete Training
Hibernate complete Training
sourabh aggarwal
 
SAP Testing Training
SAP Testing TrainingSAP Testing Training
SAP Testing Training
VGlobal Govi
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
ecosio GmbH
 
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
Jorge Hidalgo
 
Introduction to JPA (JPA version 2.0)
Introduction to JPA (JPA version 2.0)Introduction to JPA (JPA version 2.0)
Introduction to JPA (JPA version 2.0)
ejlp12
 
Session 38 - Core Java (New Features) - Part 1
Session 38 - Core Java (New Features) - Part 1Session 38 - Core Java (New Features) - Part 1
Session 38 - Core Java (New Features) - Part 1
PawanMM
 

Viewers also liked (20)

Introduction To FHA Origination
Introduction To FHA OriginationIntroduction To FHA Origination
Introduction To FHA Origination
DanMcElrath
 
Customer loan origination system
Customer loan origination systemCustomer loan origination system
Customer loan origination system
Sandeep Verma
 
Core banking has changed the way you bank
Core banking has changed the way you bankCore banking has changed the way you bank
Core banking has changed the way you bank
Sushil Deshmukh
 
fraudGUARD Insurance Presentation 2010
fraudGUARD Insurance Presentation 2010fraudGUARD Insurance Presentation 2010
fraudGUARD Insurance Presentation 2010
riskfinance
 
Mini project on core banking solutions
Mini project on core banking solutionsMini project on core banking solutions
Mini project on core banking solutions
keerthiredddy
 
Mortgage loan origination chap 6 by dr sam ruturi
Mortgage loan origination  chap 6 by dr sam ruturiMortgage loan origination  chap 6 by dr sam ruturi
Mortgage loan origination chap 6 by dr sam ruturi
samruturi
 
Customer Loan Origination System - Part 2 (Web)
Customer Loan Origination System - Part 2 (Web)Customer Loan Origination System - Part 2 (Web)
Customer Loan Origination System - Part 2 (Web)
Sandeep Verma
 
Misys acquires Custom Credit Systems, a leading provider of credit workflow ...
Misys acquires Custom Credit Systems, a leading provider  of credit workflow ...Misys acquires Custom Credit Systems, a leading provider  of credit workflow ...
Misys acquires Custom Credit Systems, a leading provider of credit workflow ...
Misys
 
Loan origination platform
Loan origination platformLoan origination platform
Loan origination platform
CapAnalec
 
Empowering dealers with new loan origination system
Empowering dealers with new loan origination systemEmpowering dealers with new loan origination system
Empowering dealers with new loan origination system
Strategybeach
 
Asset Based=Collateral Based Lending
Asset Based=Collateral Based LendingAsset Based=Collateral Based Lending
Asset Based=Collateral Based Lending
Suzy Oubre
 
Gold Loan Software | Gold Loan Management Software
Gold Loan Software | Gold Loan Management SoftwareGold Loan Software | Gold Loan Management Software
Gold Loan Software | Gold Loan Management Software
Xentric Technologies Private Limited
 
Eric Anklesaria. Secure SDLC - Core Banking
Eric Anklesaria. Secure SDLC - Core BankingEric Anklesaria. Secure SDLC - Core Banking
Eric Anklesaria. Secure SDLC - Core Banking
Positive Hack Days
 
Core Banking Solution.
Core Banking Solution.Core Banking Solution.
Core Banking Solution.
Rajat Khandelwal
 
Finacle - Menus and F Keys
Finacle - Menus and F KeysFinacle - Menus and F Keys
Finacle - Menus and F Keys
Charudutt Marathe
 
Core banking chapter 4
Core banking chapter 4Core banking chapter 4
Core banking chapter 4
Nayan Vaghela
 
Online Loan Application & Its Verification System
Online Loan Application & Its Verification SystemOnline Loan Application & Its Verification System
Online Loan Application & Its Verification System
Soban Ahmad
 
Don’t Fear Modernizing Your Core: Banking Innovation in the Digital Age
Don’t Fear Modernizing Your Core: Banking Innovation in the Digital AgeDon’t Fear Modernizing Your Core: Banking Innovation in the Digital Age
Don’t Fear Modernizing Your Core: Banking Innovation in the Digital Age
NTT DATA Consulting, Inc.
 
Chapterwise LOAN MANAGEMENT
Chapterwise LOAN MANAGEMENTChapterwise LOAN MANAGEMENT
Chapterwise LOAN MANAGEMENT
sagartimilsina
 
Audit through core banking solution
Audit through core banking solutionAudit through core banking solution
Audit through core banking solution
Charudutt Marathe
 
Introduction To FHA Origination
Introduction To FHA OriginationIntroduction To FHA Origination
Introduction To FHA Origination
DanMcElrath
 
Customer loan origination system
Customer loan origination systemCustomer loan origination system
Customer loan origination system
Sandeep Verma
 
Core banking has changed the way you bank
Core banking has changed the way you bankCore banking has changed the way you bank
Core banking has changed the way you bank
Sushil Deshmukh
 
fraudGUARD Insurance Presentation 2010
fraudGUARD Insurance Presentation 2010fraudGUARD Insurance Presentation 2010
fraudGUARD Insurance Presentation 2010
riskfinance
 
Mini project on core banking solutions
Mini project on core banking solutionsMini project on core banking solutions
Mini project on core banking solutions
keerthiredddy
 
Mortgage loan origination chap 6 by dr sam ruturi
Mortgage loan origination  chap 6 by dr sam ruturiMortgage loan origination  chap 6 by dr sam ruturi
Mortgage loan origination chap 6 by dr sam ruturi
samruturi
 
Customer Loan Origination System - Part 2 (Web)
Customer Loan Origination System - Part 2 (Web)Customer Loan Origination System - Part 2 (Web)
Customer Loan Origination System - Part 2 (Web)
Sandeep Verma
 
Misys acquires Custom Credit Systems, a leading provider of credit workflow ...
Misys acquires Custom Credit Systems, a leading provider  of credit workflow ...Misys acquires Custom Credit Systems, a leading provider  of credit workflow ...
Misys acquires Custom Credit Systems, a leading provider of credit workflow ...
Misys
 
Loan origination platform
Loan origination platformLoan origination platform
Loan origination platform
CapAnalec
 
Empowering dealers with new loan origination system
Empowering dealers with new loan origination systemEmpowering dealers with new loan origination system
Empowering dealers with new loan origination system
Strategybeach
 
Asset Based=Collateral Based Lending
Asset Based=Collateral Based LendingAsset Based=Collateral Based Lending
Asset Based=Collateral Based Lending
Suzy Oubre
 
Eric Anklesaria. Secure SDLC - Core Banking
Eric Anklesaria. Secure SDLC - Core BankingEric Anklesaria. Secure SDLC - Core Banking
Eric Anklesaria. Secure SDLC - Core Banking
Positive Hack Days
 
Core banking chapter 4
Core banking chapter 4Core banking chapter 4
Core banking chapter 4
Nayan Vaghela
 
Online Loan Application & Its Verification System
Online Loan Application & Its Verification SystemOnline Loan Application & Its Verification System
Online Loan Application & Its Verification System
Soban Ahmad
 
Don’t Fear Modernizing Your Core: Banking Innovation in the Digital Age
Don’t Fear Modernizing Your Core: Banking Innovation in the Digital AgeDon’t Fear Modernizing Your Core: Banking Innovation in the Digital Age
Don’t Fear Modernizing Your Core: Banking Innovation in the Digital Age
NTT DATA Consulting, Inc.
 
Chapterwise LOAN MANAGEMENT
Chapterwise LOAN MANAGEMENTChapterwise LOAN MANAGEMENT
Chapterwise LOAN MANAGEMENT
sagartimilsina
 
Audit through core banking solution
Audit through core banking solutionAudit through core banking solution
Audit through core banking solution
Charudutt Marathe
 
Ad

Similar to Struts 2 (20)

Struts Intro Course(1)
Struts Intro Course(1)Struts Intro Course(1)
Struts Intro Course(1)
wangjiaz
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
Ajay Khatri
 
Struts N E W
Struts N E WStruts N E W
Struts N E W
patinijava
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
Gabriel Walt
 
Actionview
ActionviewActionview
Actionview
Amal Subhash
 
Bt0083 server side programing 2
Bt0083 server side programing  2Bt0083 server side programing  2
Bt0083 server side programing 2
Techglyphs
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTHSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
AAFREEN SHAIKH
 
Using SP Metal for faster share point development
Using SP Metal for faster share point developmentUsing SP Metal for faster share point development
Using SP Metal for faster share point development
Pranav Sharma
 
Asp.net mvc training
Asp.net mvc trainingAsp.net mvc training
Asp.net mvc training
icubesystem
 
Struts 1
Struts 1Struts 1
Struts 1
Lalit Garg
 
Automation tips
Automation tipsAutomation tips
Automation tips
Ritu Mangla
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVC
Richard Paul
 
Struts Overview
Struts OverviewStruts Overview
Struts Overview
elliando dias
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
dwm042
 
Qtp Training
Qtp TrainingQtp Training
Qtp Training
mehramit
 
Asp.NET MVC
Asp.NET MVCAsp.NET MVC
Asp.NET MVC
vrluckyin
 
Android best practices
Android best practicesAndroid best practices
Android best practices
Jose Manuel Ortega Candel
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 
Struts Ppt 1
Struts Ppt 1Struts Ppt 1
Struts Ppt 1
JayaPrakash.m
 
Struts Intro Course(1)
Struts Intro Course(1)Struts Intro Course(1)
Struts Intro Course(1)
wangjiaz
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
Ajay Khatri
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
Gabriel Walt
 
Bt0083 server side programing 2
Bt0083 server side programing  2Bt0083 server side programing  2
Bt0083 server side programing 2
Techglyphs
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTHSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
AAFREEN SHAIKH
 
Using SP Metal for faster share point development
Using SP Metal for faster share point developmentUsing SP Metal for faster share point development
Using SP Metal for faster share point development
Pranav Sharma
 
Asp.net mvc training
Asp.net mvc trainingAsp.net mvc training
Asp.net mvc training
icubesystem
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVC
Richard Paul
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
dwm042
 
Qtp Training
Qtp TrainingQtp Training
Qtp Training
mehramit
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 
Ad

Recently uploaded (20)

HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 

Struts 2

  • 2.  OGNL is an expression language that is used to retrieve values from stack.  Normally when actions are called, request parameters, values passed to action, the action bean instance, all are pushed into a stack called as “Value Stack”.  The value stack holds values for the action.  OGNL is used in views to retrieve values from this stack.
  • 3.  The best thing about struts 2 is OGNL can also be used in the struts.xml file.  The following code specifies how OGNL can be used to specify values in the value stack: <action name=“ShowMail” class=“com.example.ShowMails”> <result>/mails/showMails.jsp?username=${username}</result> </action>  This means when the result page would be rendered the url would be appended with the value retrieved by the username property of the present action class i.e. ShowMails.
  • 4.  Apart from retrieving data from action class. OGNL helps retrieve data from the following objects:  #application  #session  #request  #attr  #parameters  For example the following code would fetch the value username from the user object in session. <s:property value=“#session.user.username”/>  This in essence is equivalent to: <% User user=session.getAttribute(“user”); Out.println(user.getUsername()); %>
  • 5.  Functionality for creating views in JSP is provided by Struts in the form of tag library.  The struts tag library is included in the following way in JSP pages that contain struts-tags: <%@taglib uri=“/struts-tags” prefix=“s”%>  The TLD file for the struts tags is present in the jar files of the struts libraries.
  • 6.  Struts tags fall into these two categories:  Generic Tags: Generic tags control the execution flow when pages are rendered. They are also used to extract data.  UI Tags: UI Tags are used to create user interface elements like form field etc.  Apart from the tag library, Struts 2 also provides OGNL(Object Graph Navigation Language), an intuitive way to retrieve values and embed them in views from the session, action beans etc.
  • 7.  Generic Tags are of two types:  Data Tags: They are used to retrieve data from objects and display them in web pages.  Control Tags: Control tags are used to emulate loops and decision making constructs like while, for, for and if…else.
  • 8.  The action tag: This tag is used to invoke some other action from the present page, where it is embedded. Its beneficial when you want some functionality to be invoked in the JSP page without using scriptlets.  Syntax <s:action name=“AuthenticateAction” executeResult=“true”/>
  • 9. Attribute Meaning Id For referencing the element Name The name of the action that is being called executeResult Whether the result of the action should be displayed or not Namespace Namespace of the action that has to be called Flush Whether the writer should be flushed after execution of this tag var Reference name of the action bean so that it can be used later in the page ignoreContextParams Whether the request parameters are supposed to be included while calling the action
  • 10.  The property tag: The property tag is used to inject values contained in objects into the JSP page. These values are fetched from the value stack (The value stack is a stack that contains all the objects that the action is dealing with, while the action‟s methods are called).  Syntax: <s:property value=“user.username”/>  Output: Hello Chandrakant
  • 11. Attribute Meaning id For referencing the element value The value to be displayed default If the attribute is not started then the default value that would appear in its place. escape Whether HTML would be escaped.
  • 12.  The bean tag: The bean tag is used to instantiate a class that conforms to the java bean specification. It‟s similar to jsp‟s useBean tag.  Syntax <s:bean name=“com.example.Employee” var=“emp”/>
  • 13. Attribute Meaning id For referencing the element name Name of the class whose instance is supposed to be created. var Name of the reference for the bean object that can be used later on.
  • 14.  The set tag: This tag is used to set some data into a bean instance or into one of the following:  Session scope  Application scope  Request scope  Page scope  Action(by default)  Syntax <s:set name=“firstName” scope=“session” value=“user.firstName”/>
  • 15. Attribute Meaning Id For referencing the element name Reference name of the variable that is set in the specified scope. value The value that is set scope The scope in which the value should be placed
  • 16.  The include tag: This tag is used to include certain JSP page‟s or Servlet‟s result into the present page. Its functionality similar to the jsp include action.  Syntax  <s:include value=“listAllDepartments.jsp”/>
  • 17. Attribute Meaning value The name of the JSP page or the servlet‟s alias that has to be included in the present page.
  • 18.  The url tag: The url tag is used to  Render absolute or relative URLs  Handle parameters  Encodes URL‟s so that it can be used in browsers where cookies are disabled.  Syntax <s:url action=“Login.action” var=“loginURL”> <s:param name=“useType” value=“Admin”/> </s:url>
  • 19. Attribute Meaning Id For referencing the element value The base url action Name of the target Action namespace Namespace of the action that has to be called encode Used to add session id to the url var Reference name of the url so that it can be used later in the page includeParams/include To include the parameters or the context method The method of the action that has to be called Method The method of the action that has to be used Scheme The protocol(http/https)
  • 20.  The param tag: This tag is used for providing parameters to other tags.  Syntax: <s:param name=“color”>#ff0000</s:param>
  • 21. Attribute Meaning id For referencing the element name The name of the parameters to be set value Value that has to be set for the parameter
  • 22.  Control tags used for referencing emulating control structures like loops and decision constructs.  There are basically two control tags  Iterator tag  If, elseif and else tags
  • 23.  The iterator tag is used for iterating through the collections of objects. The collections can be one of the following types:  Collections  Maps  Enumeration  Iterators  Arrays  Syntax: <s:iterator status=“num” value=“{1, 2, 3, 4, 5}”> <s:property value=“top”/> </s:iterator>
  • 24. Attribute Meaning Id For referencing the element Value The object to be iterated over Status It is used to mention whether an instance of the IteratorStatus should be pushed into the stack in each iteration.
  • 25.  The if, elseif and else tags: These tags are used to emulate an if…else if…else construct.  Syntax: <s:if test=“%{#userRole==„Admin‟}”/> <!–- Do something here.. --> </s:if> <s:elseif test=“%{#userRole==„HR‟}”/> <!–- Something else--> -- > <s:else> <!– Do what should be done if all fails. --> </s:else>
  • 26. Attribute Meaning Id For referencing the element Test The expression of that needs to be tested to determine if body of the tag would be executed.
  • 27.  UI Tags are used to generate form elements or display data in simple are reusable format.  Tags, themes and templates combine together to produce flexible, feature-rich and extensible UI components.  The struts UI tags are backed by templates that do the actual work.  Templates group together to form themes. The various themes are:  simple  ajax  Xhtml  css_xhtml
  • 28.  UI Tags are used to create form elements.  The following are few Struts UI Tags: ◦ s:form, s:textfield, s:password, s:hidden, s:textarea, s:submit, s:file, s:checkbox, s:select, s:radio, s:reset
  • 29.  Views are usually specified in the struts.xml as results of actions. For instance: <action name=“LoginScreen”> <result>login.jsp</result </action>  The result tag has a type attribute that can take the following values:  Redirect – This is specified as the value of type if we want the controller to redirect to a different page on the event of an action‟s result. This can redirect to another JSP page or servlet.  redirectAction – This is similar to redirect, however with redirectAction, the name of some other action can be specified.
  • 31.  The struts2 validation framework is one of the most comprehensive ones that struts 2 core is composed of.  Struts 2 provides support for both server-side and client-side validation.  A lot of predefined validators and ability to create and plug in custom validators adds to the validation prowess of the framework.  Struts provides both declarative and programmatic validation techniques.
  • 32.  Programmatic validation is achieved in Action classes by implementing the Validateable interface in the action class.  This interface has the void validate() method, which needs to be overridden.  Validation code is put in this function.  In case the Action class needs to report the validation errors, then it needs to implement the ValidationAware interface that has methods for error logging. These two interfaces are implemented in the ActionSupport class. So extending ActionSupport automatically makes the action class possess validation capabilities. All that needs to be done is overriding of the validate() method and reporting of the validation errors.
  • 33.  Usually programmatic validation is used in complex validation scenarios.  In case things like pattern of input data, input data length, data type(number or string or email address) have to be validated, declarative validation is a better choice.  Declarative validation is done in xml files that are present in the same directory as the Action class.  These files are named in this manner  <Action class name>-validation.xml  For instance if the name of the Action class is Employee the validation.xml file would be:  Employee-validation.xml
  • 34. <validators> <field name=“count”> <field-validator type=“int” short-circuit=“true”> <param name=“min”>1</param> <param name=“max”>100</param> <message key=“invalid.count”> value must be between ${min} and ${max} </message> </field-validator> </field> <field name=“name”> … </field> … … </validators>
  • 35.  Inside the validation xml file there can be multiple <field></field> entries, each corresponding to a property of the action class.  The <field> element may be contain one or more <field-validator> entries. Each of these field-validator represents a validation rule.  The type attribute of the <field-validator< tag specifies what kind of validation is required.  The short-circuit attribute(if set to true) would prevent the rest of the validators from validating.  Param tags can be used to specify validation parameters.
  • 36.  Validators can either act upon single fields or can act upon the whole action context.  In case a validator has to act upon the whole action context then instead of <field-validator>, the <validator> tag is used.  <validator> has a higher precedence over <field- validator>
  • 37. Validator type Parameters required fieldName requiredString fieldName, trim stringLength fieldName, maxLength, minLength, trim Int fieldName, min, max Double fieldName, maxInclusive, minExclusive, maxExclusive Date fieldName, max, min Expression Expression fieldExpression Expression Email fieldName url fieldName Conversion fieldName Regex fieldName, expression, caseSensitive, trim
  • 38.  In case errors are encountered during validation(programmatic or declarative), the result of the action automatically becomes input.  Therefore to handle result of type input, there should be an appropriate element in struts.xml.  For example: <action name=“SaveEmployeeDetails” class=“com.example.Employee”> <result name=“input”>employeeForm.jsp</result> <result name=“success”>saveSuccess.jsp</result> </action>