OGNL in struts 2

OGNL refers to Object Graph Navigation Language. It is mainly used to set or get the value of a java bean property. Use of OGNL in struts 2. As an expression language it is used in forms and response UI pages. It is used to access the objects in ValueStack. It is used in type … Read more

Multiple configuration file in Struts 2

We can break struts.xml file into multiple small files. At runtime there can be only one struts.xml for an application so other files have to be included in the default struts.xml file. Syntax: <struts> //Other attributes <include file="strutsfile1.xml"/> <include file="strutsfile2.xml"/> //Other attributes </struts><struts> //Other attributes <include file="strutsfile1.xml"/> <include file="strutsfile2.xml"/> //Other attributes </struts> Example: login.jsp <%@ … Read more

Struts 2 Hello World example

Let us start with a simple struts program to say “Hello World”. If you not have the knowledge of struts architecture and configuration files then kindly go through these first. Example: login.jsp <%@ taglib uri="/struts-tags" prefix="s"%> <html> <head> <title>Struts 2 Hello World example</title> </head> <body> <h3>This is a Hello World example.</h3>   <s:form action="Login"> <s:textfield … Read more

Action in struts 2 by extending ActionSupport class

ActionSupport class implements a no. of interfaces like Action, Validateable, LocaleProvider and Serializable etc. It is more commonly used instead of Action interface. Example: login.jsp <%@ taglib uri="/struts-tags" prefix="s"%> <html> <head> <title>Struts 2 ActionSupport class extends example</title> </head> <body> <h3>This is an ActionSupport class extends example.</h3>   <s:property value="message" /> <br/>   <s:form action="Login"> <s:textfield … Read more

Action in struts 2 by implementing Action interface

Action interface defines five constants and one no-argument method. Action interface. public interface Action { public static final String SUCCESS = "success"; public static final String NONE = "none"; public static final String ERROR = "error"; public static final String INPUT = "input"; public static final String LOGIN = "login"; public String execute() throws Exception; … Read more

Action in struts 2 by using POJO class

As we discussed in earlier tutorials that any POJO class can be used as action class in struts 2. Only requirement is that it must have one no-argument method that returns a String or Result object. The execute() method is used by default if no-argument method is not there. Example: login.jsp <%@ taglib uri="/struts-tags" prefix="s"%> … Read more

Action in struts 2

Actions: Actions are the core element of struts 2. Actions contain the necessary processing logic to complete the request from the user. Actions are also used to interact with the other layers like view layer. How to create Action in struts 2? In struts 2 an action can be created by following ways: Action in … Read more

Struts 2 Configuration Files

Struts.xml file: The struts.xml is the core configuration file for struts framework. The struts.xml is used to initialize the resources like Interceptors, Action classes and Results. Syntax: <struts>   <package name="packageName" extends="struts-default">   <action name="actionName" class="actionClass" method="methodName"> <result name="success">/HelloWorld.jsp</result> </action>   //more actions.   </package>   //more packages.   </struts><struts> <package name="packageName" extends="struts-default"> <action name="actionName" … Read more

Struts 2 Architecture

Sturts 2 MVC framework contains the following core components: Actions. Interceptors. Value Stack / OGNL Result types Diagram: Struts 2 request life cycle: When a request comes web container maps the request in the web.xml and calls the controller (FilterDispatcher). FilterDispatcher calls the ActionMapper to find an Action to be invoked. FilterDispatcher calls the ActionProxy. … Read more

SQL Functions

SQL provides no. of inbuilt functions which perform calculations on groups of rows and return one value for the whole group. Commonly used SQL functions: 1. SQL AVG(): It is used to get the average value of a numeric column. Syntax: SELECT AVG(columnName) FROM tableName;   2. SQL COUNT(): It is used to get the … Read more

Categories SQL