Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Struts 2 ActionAction InterfaceActionSup, Essays (university) of Software Engineering

Hj jkkkg kkjff kkkkgf. Kkjt. Lurd kkb

Typology: Essays (university)

2018/2019

Uploaded on 11/04/2019

arey-entra
arey-entra 🇬🇧

1 document

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Struts 2 Action
In struts 2, action class is POJO (Plain Old Java Object).
POJO means you are not forced to implement any interface or
extend any class.
Generally, execute method should be specified that represents
the business logic. The simple action class may look like:
Welcome.java
1. package com.javatpoint;
2. public class Welcome {
3. public String execute(){
4. return "success";
5. }
6. }
Action Interface
A convenient approach is to implement the
com.opensymphony.xwork2.Action interface that defines 5
constants and one execute method.
04/11/19, 11:06 PM
Page 1 of 8
pf3
pf4
pf5
pf8

Partial preview of the text

Download Struts 2 ActionAction InterfaceActionSup and more Essays (university) Software Engineering in PDF only on Docsity!

Struts 2 Action

In struts 2, action class is POJO (Plain Old Java Object). POJO means you are not forced to implement any interface or extend any class. Generally, execute method should be specified that represents the business logic. The simple action class may look like: Welcome.java

  1. package com.javatpoint;
  2. public class Welcome {
  3. public String execute(){
  4. return "success";
  5. }
  6. }

Action Interface

A convenient approach is to implement the com.opensymphony.xwork2.Action interface that defines 5 constants and one execute method.

5 Constants of Action Interface

Action interface provides 5 constants that can be returned form the action class. They are:

  1. SUCCESS indicates that action execution is successful and a success result should be shown to the user.
  2. ERROR indicates that action execution is failed and a error result should be shown to the user.
  3. LOGIN indicates that user is not logged-in and a login result should be shown to the user.
  4. INPUT indicates that validation is failed and a input result should be shown to the user again.
  5. NONE indicates that action execution is successful but no result should be shown to the user. Let's see what values are assigned to these constants:
  6. public static final String SUCCESS = "success";
  7. public static final String ERROR = "error";
  8. public static final String LOGIN = "login";
  9. public static final String INPUT = "input";
  10. public static final String NONE = "none";

JEE main & Advanced coaching

Learn from best: IIT Topper Dr. Balaji Sampath! Sign up today for special price ahaguru.com OPEN Replay

<>

It is a convenient class that implements many interfaces such as Action, Validateable, ValidationAware, TextProvider, LocaleProvider and Serializable. So it is mostly used instead of Action.

Example of Struts Action that extends ActionSupport

class

Let's see the example of Action class that extends the ActionSupport class. Welcome.java

  1. package com.javatpoint;
  2. import com.opensymphony.xwork2.ActionSupport;
  3. public class Welcome extends ActionSupport{
  4. public String execute(){
  5. return SUCCESS;
  6. }
  7. } JEE Mains Coaching At AhaGuru Start Learning Now

Build Your Skills With Smart Practice. Learn Innovative

Problem Techniques!

ahaguru.com OPEN

Placement Papers TCS HCL Infosys IBM Accenture AMCAT eLitmas Java Python C Programming Networking Bank PO/Clerk UPSSSC Government Exams SSC Civil Services SBI Please Share Join Javatpoint Test Series GATE NEET CAT Railway CTET IIT JEE Learn Latest Tutorials

Immediate Loans in Hyderabad

Cash Loan in Hyderabad–Apply Online to get Instant Loan. Avail Quick Loan Upto ₹5 Lakh

StashFin Personal Loan Apply Now

AI AWS Selenium

IoT Cloud Hadoop

ReactJS React Native Node.js

D. Science Angular 7 Blockchain

DBMS DS DAA

OS C. Network Compiler D.

Trending Technologies B.Tech / MCA

COA D. Math. E. Hacking

C. Graphics Software E. Web Tech.

Cyber Sec. Automata C

C++ Java .Net

Python Programs Control S.