50+ TOP Apache Avro Interview Questions and Answers [UPDATED]

If you’re preparing for Apache Avro job interview and whether you’re experienced or fresher & don’t know what kind of questions will be asked in Apache Avro interview, then go through the below 50+ Top Apache Avro Interview Questions and Answers to crack your job interview.

Apache Avro Interview Questions and Answers

  • Question : Explain Some Advantages Of Avro.
    Answer :

    Pros of Avro are:

    • The Smallest Size.
    • It Compresses block at a time; split table.
    • Maintained Object structure.
    • Also, supports reading old data w/ new schema.
  • Question : Explain Some Disadvantages Of Avro.
    Answer :

    Cons of Avro are:

    • It is must to use .NET 4.5, in the case of C# Avro, to make the best use of it.
    • Potentially slower serialization.
    • In order to read/write data, need a schema.
  • Question : Explain Sort Order In Brief?
    Answer :

    There is a standard sort order for data in Avro which allows data written by one system to be efficiently sorted by another system. As sort order comparisons are sometimes the most frequent per-object operation, it can be an important optimization.

  • Question : Explain The Avro Sasl Profile?
    Answer :

    Basically, SASL offers a framework for authentication and security of network protocols. In Avro also we use SASL Profile for authentication and security purpose.

  • Question : Explain The Term Serialization?
    Answer :

    To transport the data over the network or to store on some persistent storage, the process of translating data structures or objects state into binary or textual form is what we call Serialization. In other words, serialization is also known as as marshaling and deserialization is known as unmarshalling.

  • Question : Name Some Avro Reference Apis?
    Answer :

    The classes and methods which we use in the serialization, as well as deserialization of Avro schemas, are:

    • Specific Datum Writer Class
    • Specific Datum Reader Class
    • Data File Writer
    • Data File Reader
    • Class Schema. Parser
    • Interface Generic Record
    • Class Generic Data. Record
  • Question : Name Some Complex Types Of Data Types, Avro Supports.
    Answer :

    There are six kinds of complex types which Avro supports:

    • Records
    • Enums
    • Arrays
    • Maps
    • Unions
    • Fixed
  • Question : Name Some Primitive Types Of Data Types, Avro Supports.
    Answer :

    Avro supports a wide range of Primitive datatypes:

    • Null: no value
    • Boolean: a binary value
    • Int: 32-bit signed integer
    • Long: 64-bit signed integer
    • Float: single precision (32-bit) IEEE 754 floating-point number
    • Double: double precision (64-bit) IEEE 754 floating-point number
    • Bytes: the sequence of 8-bit unsigned bytes
    • String: Unicode character sequence
  • Question : What Are Best Features Of Apache Avro?
    Answer :

    Some of the best features of Avro are:

    • Schema evolution
    • Untagged data
    • Language support
    • Transparent compression
    • Dynamic typing
    • Native support in MapReduce
    • Rich data structures
  • Question : What Are The Disadvantages Of Hadoop Serialization?
    Answer :

    The only disadvantage of Hadoop Serialization is that the Writable and Sequence Files have only a Java API. Hence to solve this issue, Avro comes in picture.

  • Question : What Do You Mean By Schema Declaration?
    Answer :

    In JSON, a Schema is represented by one of:

    • A JSON string
    • A JSON object

    {“type”: “typename” …attributes…}

    • A JSON array
  • Question : What Do You Mean By Schema Resolution?
    Answer :

    Whether from an RPC or a file, a reader of Avro data, can always parse that data since its schema is offered. Yet it is possible that schema may not be exactly the schema what we expect so for that purpose we use Schema Resolution.

  • Question : What Is The Advantage Of Hadoop Over Java Serialization?
    Answer :

    As with the help of the Writable objects, Hadoop Writable-based serialization is able to reduce object-creation overhead, which is not possible with the Java native serialization framework that’s why using Hadoop one is an advantage.

  • Question : What Is The Way Of Creating Avro Schemas?
    Answer :

    In the format “lightweight text-based data interchange”, JavaScript Object Notation (JSON), the Avro schema gets created.

    We can make it in various ways:−

    • A JSON string
    • JSON object
    • A JSON array
  • Question : When To Use Avro, Explain?
    Answer :

    Mainly, for two purposes, we use Avro, like:

    • Data serialization
    • RPC (Remote procedure call) protocol

    Although, some key points are:

    • We are able to read the data from disk with applications, by using Avro even which are written in other languages besides java or the JVM.
    • Also, Avro allows us to transfer data across a remote system without any overhead of java serialization.
    • We use Avro when we need to store the large set of data on disk, as it conserves space.
    • Further, by using Avro for RPC, we get a better remote data transfer.
  • Question : Who Developed Apache Avro?
    Answer :

    By Doug Cutting, the father of Hadoop, Apache AVRO was developed.

  • Question : Explain Avro Schemas?
    Answer :

    Mainly, Avro heavily depends on its schema. Basically, it permits every data to be written with no prior knowledge of the schema. We can say Avro serialized fast and the data resulting after serialization is least in size with schemas.

  • Question : Explain Thrift & Protocol Buffers Vs. Avro?
    Answer :

    The most competent libraries with Avro are Thrift and Protocol Buffers.

    The difference between them is: −

    • As per the need, Avro supports both dynamic and static types. Basically, to specify schemas and their types, Protocol Buffers and Thrift uses Interface Definition Languages (IDLs).
    • As Avro is built in the Hadoop ecosystem but Thrift and Protocol Buffers are not.
  • Question : How To Use Avro?
    Answer :

    The workflow to use Avro is:−

    We need to create schemas at first to read the schemas into our program that is possible in two ways.

    • Generating a Class Corresponding to Schema
    • Using Parsers Library

    Then perform the serialization by using serialization API provided for Avro. And then perform deserialization by using deserialization API provided for Avro.

  • Question : State Some Key Points About Apache Avro?
    Answer :

    Some key points are:

    • Avro is a Data serialization system
    • It uses JSON based schemas
    • Moreover, to send data, it uses RPC calls.
    • And, during data exchange, Schema’s sent.
  • Question : What Are Prerequisites To Learn Avro?
    Answer :

    Those who want to learn Avro must know Hadoop’s architecture and APIs, before learning Avro. Also must know Java with experience in writing basic applications before going for Avro.

  • Question : What Avro Offers?
    Answer :

    Avro offers:

    • Avro offers Rich data structures.
    • And, a compact, fast, binary data format.
    • Further, it offers a container file, to store persistent data.
    • Remote procedure calls (RPC).
  • Question : What Is Apache Avro?
    Answer :

    An open source project which offers data serialization as well as data exchange services for Apache Hadoop is what we call Apache Avro. It is possible to use these services together or independently both. However, programs can efficiently serialize data into files or into messages, with the serialization service. In addition, data storage is very compact and efficient in Avo because here data definition is in JSON, so, data itself is stored in the binary format making it compact and efficient.

  • Question : Who Is Intended Audience To Learn Avro?
    Answer :

    Those people who want to learn the basics of Big Data Analytics by using Hadoop Framework and also those who aspire to become a successful Hadoop developer can go for Avro. Further, those aspirants who want to use Avro for data serialization and deserialization can also learn Avro.

  • Question : Why Avro?
    Answer :

    Some features where Avro differs from other systems are:

    • Dynamic typing.
    • Untagged data.
    • No manually-assigned field IDs.
  • 50+ TOP Apache ZooKeeper Interview Questions and Answers [UPDATED]

  • Question: What Is ZooKeeper?

    Answer :

    ZooKeeper is a distributed co-ordination service to manage large set of hosts. Co-ordinating and managing a service in a distributed environment is a complicated process. ZooKeeper solves this issue with its simple architecture and API. ZooKeeper allows developers to focus on core application logic without worrying about the distributed nature of the application.

    The ZooKeeper framework was originally built at “Yahoo!” for accessing their applications in an easy and robust manner. Later, Apache ZooKeeper became a standard for organized service used by Hadoop, HBase, and other distributed frameworks.

  • Question: Explain The Cli In Zookeeper?

    Answer :

    ZooKeeper Command Line Interface (CLI) is used to interact with the ZooKeeper ensemble for development purpose. It is useful for debugging and working around with different options. To perform ZooKeeper CLI operations, first turn on your ZooKeeper server (“bin/zkServer.sh start”) and then, ZooKeeper client (“bin/zkCli.sh”).

    Once the client starts, you can perform the following operation:

    • Create znodes
    • Get data
    • Watch znode for changes
    • Set data
    • Create children of a znode
    • List children of a znode
    • Check Status
    • Remove / Delete a znode
  • Question: Explain The Methods Of Zookeeperclass?

    Answer :

    The central part of the ZooKeeper API is ZooKeeper class. It provides options to connect the ZooKeeper ensemble in its constructor and has the following methods –

    connect – connect to the ZooKeeper ensemble

    ZooKeeper(String connectionString, int sessionTimeout, Watcher watcher)

    create – create a znode

    create(String path, byte[] data, List acl, CreateMode createMode)

    exists – check whether a znode exists and its information

    exists(String path, boolean watcher)

    getData – get data from a particular znode

    getData(String path, Watcher watcher, Stat stat)

    setData – set data in a particular znode

    setData(String path, byte[] data, int version)

    getChildren – get all sub-nodes available in a particular znode

    getChildren(String path, Watcher watcher)

    delete – get a particular znode and all its children

    delete(String path, int version)

    close – close a connection

  • Question: Explain The Types Of Znodes?

    Answer :

    Znodes are categorized as persistence, sequential, and ephemeral.

    Persistence znode – Persistence znode is alive even after the client, which created that particular znode, is disconnected. By default, all znodes are persistent unless otherwise specified.

    Ephemeral znode – Ephemeral znodes are active until the client is alive. When a client gets disconnected from the ZooKeeper ensemble, then the ephemeral znodes get deleted automatically. For this reason, only ephemeral znodes are not allowed to have a children further. If an ephemeral znode is deleted, then the next suitable node will fill its position. Ephemeral znodes play an important role in Leader election.

    Sequential znode – Sequential znodes can be either persistent or ephemeral. When a new znode is created as a sequential znode, then ZooKeeper sets the path of the znode by attaching a 10 digit sequence number to the original name. For example, if a znode with path /myapp is created as a sequential znode, ZooKeeper will change the path to /myapp0000000001 and set the next sequence number as 0000000002. If two sequential znodes are created concurrently, then ZooKeeper never uses the same number for each znode. Sequential znodes play an important role in Locking and Synchronization.

  • Question: Explain The Zookeeper Workflow?

    Answer :

    Once a ZooKeeper ensemble starts, it will wait for the clients to connect. Clients will connect to one of the nodes in the ZooKeeper ensemble. It may be a leader or a follower node. Once a client is connected, the node assigns a session ID to the particular client and sends an acknowledgement to the client. If the client does not get an acknowledgment, it simply tries to connect another node in the ZooKeeper ensemble. Once connected to a node, the client will send heartbeats to the node in a regular interval to make sure that the connection is not lost.

    If a client wants to read a particular znode, it sends a read request to the node with the znode path and the node returns the requested znode by getting it from its own database. For this reason, reads are fast in ZooKeeper ensemble.

    If a client wants to store data in the ZooKeeper ensemble, it sends the znode path and the data to the server. The connected server will forward the request to the leader and then the leader will reissue the writing request to all the followers. If only a majority of the nodes respond successfully, then the write request will succeed and a successful return code will be sent to the client. Otherwise, the write request will fail. The strict majority of nodes is called as Quorum.

  • Question: How Can We Create Children / Sub-znode?

    Answer :

    Creating children is similar to creating new znodes. The only difference is that the path of the child znode will have the parent path as well.

    create /parent/path/subnode/path /data

  • Question: How Can We Create Znodes?

    Answer :

    Create a znode with the given path. The flag argument specifies whether the created znode will be ephemeral, persistent, or sequential. By default, all znodes are persistent.

    • Ephemeral znodes (flag: e) will be automatically deleted when a session expires or when the client disconnects.
    • Sequential znodes guaranty that the znode path will be unique.
    • ZooKeeper ensemble will add sequence number along with 10 digit padding to the znode path. For example, the znode path /myapp will be converted to /myapp0000000001 and the next sequence number will be /myapp0000000002.

    If no flags are specified, then the znode is considered as persistent.

    create /path /data

    To create a Sequential znode, add -s flag as shown below.

    create -s /path /data

    To create an Ephemeral Znode, add -e flag as shown below.

    create -e /path /data

  • Question: How Can We Remove A Znode?

    Answer :

    Removes a specified znode and recursively all its children. This would happen only if such a znode is available.

    rmr /path

  • Question: Mention Some Instances Where Zookeeper Is Using?

    Answer :

    Below are some of instances where Apache ZooKeeper is being utilized:

    • Apache Storm, being a real time stateless processing/computing framework, manages its state in ZooKeeper Service
    • Apache Kafka uses it for choosing leader node for the topic partitions
    • Apache YARN relies on it for the automatic failover of resource manager (master node)
    • Yahoo! utilties it as the coordination and failure recovery service for Yahoo! Message Broker, which is a highly scalable publish-subscribe system managing thousands of topics for replication and data delivery. It is used by the Fetching Service for Yahoo! crawler, where it also manages failure recovery.
  • Question: What Are The Basics Of Zookeeper Api?

    Answer :

    Application interacting with ZooKeeper ensemble is referred as ZooKeeper Client or simply Client. Znode is the core component of ZooKeeper ensemble and ZooKeeper API provides a small set of methods to manipulate all the details of znode with ZooKeeper ensemble. A client should follow the steps given below to have a clear and clean interaction with ZooKeeper ensemble.

    • Connect to the ZooKeeper ensemble. ZooKeeper ensemble assign a Session ID for the client.
    • Send heartbeats to the server periodically. Otherwise, the ZooKeeper ensemble expires the Session ID and the client needs to reconnect.
    • Get / Set the znodes as long as a session ID is active.
    • Disconnect from the ZooKeeper ensemble, once all the tasks are completed. If the client is inactive for a prolonged time, then the ZooKeeper ensemble will automatically disconnect the client.
  • Question: What Are The Benefits Of Distributed Applications?

    Answer :

    Reliability:Failure of a single or a few systems does not make the whole system to fail.

    Scalability : Performance can be increased as and when needed by adding more machines with minor change in the configuration of the application with no downtime.

    Transparency: Hides the complexity of the system and shows itself as a single entity / application.

  • Question: What Are The Benefits Of Zookeeper?

    Answer :

    Here are the benefits of using ZooKeeper:

    • Simple distributed coordination process
    • Synchronization:Mutual exclusion and co-operation between server processes. This process helps in Apache HBase for configuration management.
    • Ordered Messages
    • Serialization :Encode the data according to specific rules. Ensure your application runs consistently. This approach can be used in MapReduce to coordinate queue to execute running threads.
    • Reliability
    • Atomicity:Data transfer either succeed or fail completely, but no transaction is partial.
  • Question: What Are The Challenges Of Distributed Applications?

    Answer :

    Race condition: Two or more machines trying to perform a particular task, which actually needs to be done only by a single machine at any given time. For example, shared resources should only be modified by a single machine at any given time.

    Deadlock:Two or more operations waiting for each other to complete indefinitely.

    Inconsistency:Partial failure of data.

  • Question: What Is Apache Zookeeper Meant For?

    Answer :

    Apache ZooKeeper is a service used by a cluster (group of nodes) to coordinate between themselves and maintain shared data with robust synchronization techniques. ZooKeeper is itself a distributed application providing services for writing a distributed application.

    The common services provided by ZooKeeper are as follows :

    Naming service:Identifying the nodes in a cluster by name. It is similar to DNS, but for nodes.

    Configuration management: Latest and up-to-date configuration information of the system for a joining node.

    Cluster management:Joining / leaving of a node in a cluster and node status at real time.

    Leader election:Electing a node as leader for coordination purpose.

    Locking and synchronization service:Locking the data while modifying it. This mechanism helps you in automatic fail recovery while connecting other distributed applications like Apache HBase.

    Highly reliable data registry:Availability of data even when one or a few nodes are down.

  • Apache ZooKeeper Questions and Answers for Interview

    Preparing for Apache ZooKeeper job interview and whether you’re experienced or fresher & don’t know what kind of questions will be asked in Apache ZooKeeper interview, then go through the above 50+ Top Apache ZooKeeper Interview Questions and Answers to crack your job interview.

    70+ TOP Apache Wicket Interview Questions and Answers [UPDATED]

  • Question: Dependency To Start Wicket?

    Answer :






    Wicket need SLF4J !

    You have to include the slf4j logging implementation, otherwise Wicket will be failed to start.

    Wicket need resource filter

    Remember to add the resource filter, Wicket puts all files in same package folder, if you didn’t define the resource filter to include everything “<include>*</include>” , “html”, “properties” or other resources files may failed to copy to the correct target folder.

  • Question: How To Create 404 Error Page?

    Answer :











    public class WicketApplication extends WebApplication {


    protected void init() {

      mount(new QueryStringUrlCodingStrategy(“error404”,ErrorPage404.class));



  • Question: How To Create A Password Field In Apache-wicket?

    Answer :

    create a password field

    final PasswordTextField password = new PasswordTextField(“password”, Model.of(“”));

    //for properties file


  • Question: How To Create A Textarea In Apache-wicket?

    Answer :

    //create a textarea field for address

    final TextArea<String> address = new TextArea<String>(“address”,Model.of(“”));


  • Question: How To Create A Textfield In Apache-wicket?

    Answer :

    final TextField username = new TextField(“username”,Model.of(“”));


    username.add(new Username  Validator());

  • Question: How To Create Checkbox In Apache-wicket?

    Answer :

    final CheckBox chk0 = new CheckBox(“checkbox0”, Model.of(Boolean.TRUE));

     final CheckBox chk1 = new CheckBox(“checkbox1”,

    new PropertyModel<Boolean>(this, “checkbox1”));

    final CheckBox chk2 = new CheckBox(“checkbox2”,

    new PropertyModel<Boolean>(this, “checkbox2”));

  • Question: How To Create Custom Validator In Apache-wicket?

    Answer :

    See summary steps to create a custom validator :

    1. Implements IValidator.

    import org.apache.wicket.validation.IValidator;

     public class Strong PasswordValidator implements IValidator<String>{


    2. Override validate(IValidatable validatable).

    public class StrongPasswordValidator implements IValidator<String>{


    public void validate(IValidatable<String> validatable) {

      //get input from attached component

    final String field = validatable.getValue();



    3. Attached custom validator to form component.

    public class CustomValidatorPage extends WebPage {

      public CustomValidatorPage(final PageParameters parameters) {

           final PasswordTextField password = new PasswordTextField(“password”,Model.of(“”));

    //attached custom validator to password field

    password.add(new StrongPasswordValidator());




  • Question: How To Create Dropdown Choice In Apache-wicket?

    Answer :


    import org.apache.wicket.markup.html.form.DropDownChoice;

    //choices in dropdown box

    private static final List<String> SEARCH_ENGINES = Arrays.asList(new String[] {

    “Google”, “Bing”, “Baidu” });

     //variable to hold the selected value from dropdown box,

    //and also make “Google” is selected by default

    private String selected = “Google”;

     DropDownChoice<String> listSites = new DropDownChoice<String>(

    “sites”, new PropertyModel<String>(this, “selected”), SEARCH_ENGINES);

     //HTML for dropdown box

    <select wicket:id=”sites”></select>

  • Question: How To Create Fileupload Field In Apache-wicket?

    Answer :


    import org.apache.wicket.markup.html.form.upload.FileUploadField;


    form.add(fileUpload = new FileUploadField(“fileUpload”));


    <input wicket:id=”fileUpload” type=”file”/>

  • Question: How To Create Multiple Checkboxes In Apache-wicket?

    Answer :

    private static final List<String> LANGUAGES = Arrays.asList(new String[] {“Java”, “.NET”, “PHP”, “Python”, “C/C++” });

    // hold the checkbox values

    private ArrayList<String> languagesSelect = new ArrayList<String>();

    final CheckBoxMultipleChoice<String> listLanguages = new CheckBoxMultipleChoice<String>(“languages”, new Model(languagesSelect), LANGUAGES);

  • Question: How To Create Multiple Selected Listbox In Apache-wicket?

    Answer :

    //choices in list box

    private static final List<String> NUMBERS = Arrays.asList(new String[] {“Number 1”, “Number 2”, “Number 3”, “Number 4”, “Number 5”, “Number 6” });

    //variable to hold the selected multiple values from listbox, 

    //and make “Number 6” selected as default value

    private ArrayList<String> selectedNumber = new ArrayList<String>(

    Arrays.asList(new String[] { “Number 6” }));

     ListMultipleChoice<String> listNumbers = new ListMultipleChoice<String>(

    “number”, new Model(selectedNumber), NUMBERS);

     //HTML for multiple select listbox

    <select wicket:id=”number”></select>

  • Question: How To Create Radio Button In Apache-wicket?

    Answer :

    //choices in radio button

    private static final List<String> TYPES = Arrays.asList(new String[] { “Shared Host”, “VPN”, “Dedicated Server” });

    RadioChoice<String> hostingType = new RadioChoice<String>(“hosting”, new PropertyModel<String>(this, “selected”), TYPES);

  • Question: How To Create Select Option As Menu Wise In Apache-wicket?

    Answer :


    import org.apache.wicket.extensions.markup.html.form.select.Select;

    import org.apache.wicket.extensions.markup.html.form.select.SelectOption;

            //variable to hold the selected value from dropdown box,

            //and also make “jQuery” selected by default

            private String selected = “jQuery”;

      Select languages = new Select(“languages”, new PropertyModel<String>(this, “selected”));


    languages.add(new SelectOption<String>(“framework1”, new Model<String>(“Wicket”)));

    languages.add(new SelectOption<String>(“framework2”, new Model<String>(“Spring MVC”)));

    languages.add(new SelectOption<String>(“framework3”, new Model<String>(“JSF 2.0”)));

    languages.add(new SelectOption<String>(“Script1”, new Model<String>(“jQuery”)));

    languages.add(new SelectOption<String>(“Script2”, new Model<String>(“prototype”)));

     //HTML for dropdown box

    <select wicket:id=”languages”>

    <optgroup label=”Frameworks”>

    <option wicket:id=”framework1″ >Wicket (1.4.7)</option>

    <option wicket:id=”framework2″ >Spring MVC (3.0)</option>

    <option wicket:id=”framework3″ >JSF (2.0)</option>


    <optgroup label=”JavaScript”>

    <option wicket:id=”Script1″ >jQuery (1.6.1)</option>

    <option wicket:id=”Script2″ >prototype (1.7)</option>



  • Question: How To Create Single Selected Listbox?

    Answer :

    // single list choice

    private static final List<String> FRUITS = Arrays.asList(new String[] { “Apple”, “Orange”, “Banana” });

    ListChoice<String> listFruits = new ListChoice<String>(“fruit”, new PropertyModel<String>(this, “selectedFruit”), FRUITS);


  • Question: How To Get Servletcontext In Apache-wicket Application?

    Answer :

    Yes, you can get the ServletContext class via Wicket’s WebApplication class like this :

    import javax.servlet.ServletContext;

    import org.apache.wicket.Page;

    import org.apache.wicket.protocol.http.WebApplication;

    import com.withoutbook.hello.Hello;

     public class CustomApplication extends WebApplication {


    public Class<? extends Page> getHomePage() {

      ServletContext servletContext = WebApplication.get().getServletContext();

    return Hello.class; //return default page



  • Question: How To Integrate Apache-wicket With Spring?

    Answer :

    Override Wicket application init() method with this “addComponentInstantiationListener(new SpringComponentInjector(this));“.

    File : Wicket application class

    package com.withoutbook;

     import org.apache.wicket.protocol.http.WebApplication;

    import org.apache.wicket.spring.injection.annot.SpringComponentInjector;

    import com.withoutbook.user.SimplePage;

     public class WicketApplication extends WebApplication {


    public Class<SimplePage> getHomePage() {

      return SimplePage.class; // return default page



    protected void init() {


    addComponentInstantiationListener(new SpringComponentInjector(this));



    Now, you can inject Spring bean into Wicket component via @SpringBean.

  • Question: How To Keep File Validation In Apache-wicket If No File Has Been Selected?

    Answer :

    To fix it, just override the validateOnNullValue() method like this :

    FileUploadField fileUpload = new FileUploadField(“fileupload”,new Model<FileUpload>());

     fileUpload .add(new AbstractValidator() { 

            public boolean validateOnNullValue(){

            return true;


      protected void onValidate(IValidatable validatable) { 

    FileUpload fileUpload = (FileUpload) validatable.getValue();


         protected String resourceKey() {

        return “yourErrorKey”;



    Now, when no file is selected, and submit button is clicked, validation will be performed.

  • Question: How To Submit A Form In Apache-wicket?

    Answer :

    Form<?> form = new Form<Void>(“userForm”) {


    protected void onSubmit() {

      final String usernameValue = username.getModelObject();

      PageParameters pageParameters = new PageParameters();

    pageParameters.add(“username”, usernameValue);

    setResponsePage(SuccessPage.class, pageParameters);



  • Question: Tell Me The Example Of Username Validation In Apache-wicket?

    Answer :

    import org.apache.wicket.validation.CompoundValidator;

    import org.apache.wicket.validation.validator.PatternValidator;

    import org.apache.wicket.validation.validator.StringValidator;

     public class UsernameValidator extends CompoundValidator<String> {

      private static final long serialVersionUID = 1L;

      public UsernameValidator() {

      add(StringValidator.lengthBetween(6, 15));

    add(new PatternValidator(“[a-z0-9_-]+”));



  • Question: What Are The Ways To Create A Page In Wicket?

    Answer :

    There are 2 ways to Create New Wicket Page.

    • create a Page Extending “WebPage” Class.
    • create a Page Extending  “BasePage” ( BasePage Should Extend “WebPage”).
    • IF you are using first Way you should Create Whole page with thier Header,Footer and other parts
    • and that HTML file’s content may be large (complicated).This is an Unreliable way to create Page. suppose you have to change some content in Header part then you have to edit all pages that having Header Content 
    • If you are using second way, first Create your BasePage then you can extend these page to other while creating new page. in that page you have to add only Body part (Content that you want to show on that Page) Using <wicket:child />
  • Question: What Are Wicket Models?

    Answer :

    A Model holds a value for a component to display and/or edit :

    • Simple Models
    • Dynamic Models
    • Property Models
    • Compound Property Models
    • Wrapped Object Models
    • Resource Models
    • Detachable Models
    • Chaining models
  • Question: What Is About Web Application In Wicket?

    Answer :

    A web application is a subclass of Application which associates with an instance of WicketServlet to serve pages over the HTTP protocol. This class is intended to be subclassed by framework clients to define a web application.

  • Question: What Is Base Class For Html Pages?

    Answer :

    Base class for HTML pages: Webpage Class.

  • Question: What Is Pallet Component In Apache-wicket?

    Answer :

    Wicket extension comes with a special “Palette” component, which render two select boxes, and allow user to move items from one select box into another.


    import org.apache.wicket.extensions.markup.html.form.palette.Palette;

     final Palette<Hosting> palette = new Palette<Hosting>(“palette”,

    new ListModel<Hosting>(selected),

    new CollectionModel<Hosting>(listHosting),

    renderer, 10, true);


    <span wicket:id=”palette”></span>

  • Question: What Is Wicket Framework?

    Answer :

    • Wicket is one of the most recent in a long line of Java web development frameworks.Wicket is a component-basedframework, which puts it in stark contrast to some of the earlier solutions to the sometimes monotonous task of web programming.Wicket builds on top of Sun’s servlet API. Wicket is mostly removed from the request/response nature that is inherent with the web and Servlets. Instead of building controllers that must service many users and threads simultaneously, taking in requests, returning responses, and never storing any state, the Wicket developer thinks in terms of stateful components. Instead of creating a controller or action class, he or she creates a page, places components on it, and defines how each component reacts to user input.
    • It is a lightweight component-based web application framework for the Java programming.
  • Apache Wicket Questions and Answers for Interview

    Preparing for Apache Wicket job interview and whether you’re experienced or fresher & don’t know what kind of questions will be asked in Apache Wicket interview, then go through the above 70+ Top Apache Wicket Interview Questions and Answers to crack your job interview.

    100+ TOP Apache Web Server (Level 2) Interview Questions and Answers [UPDATED]

  • Question: How To Stop/start Apache Web Server?
    Answer :

    You can restart by going to Apache instance location >> bin folder and execute apachectl script.

    ./apachectl stop

    ./apachectl start

    You may also use script located in /etc/init.d/. Mostly it will be named either “apache” or “httpd”

    /etc/init.d/apache stop

    /etc/init.d/apache start

    Another procedure would be using services

    httpd stop

    service httpd start

  • Question: Can You Change The Listening Port From Default To Something Else?
    Answer :

    Yes, it’s possible by specifying the port number in Listen directive.

    For ex: to make Apache listen on 9000 port to IP address.


  • Question: Can You Tell Me The Important Configuration File Name?
    Answer :

    httpd.conf is the main configuration file used in Apache.

  • Question: How Can Apache Act A Proxy Server?
    Answer :

    You can use a mod_proxy module to use as a proxy server. The mod_proxy module can be used to connect to the backend server like Tomcat, WebLogic, WebSphere, etc.

  • Question: How Do I Disable Directory Indexing?
    Answer :

    You can use “Options -Indexes” in respective directory directive.

    Options -Indexes

    Options -Indexes


  • Question: How To Check The Version Of Running Apache Web Server?
    Answer :

    There is multiple ways to find this but more accurately would be;

    • Login to web server
    • Go to apache instance and bin folder
    • Executed httpd with -v to get the version details.

    [root@lab sbin]# ./httpd -v

    Server version: Apache/2.2.15 (Unix)

    Server built:   Jul 18 2016 15:24:00

    [root@lab sbin]#

    Alternatively, you can also use the rpm command to check the installed version:

    [root@lab ~]# rpm -qa |grep httpd



    [root@lab ~]#

  • Question: How To Create A Csr?
    Answer :

    You can either use the following OpenSSL command or generate CSR online.

    To create new CSR with private key

    openssl req -out geekflare.csr -newkey rsa:2048 -nodes -keyout geekflare.key

    Check out OpenSSL cheat sheet for more commands.

  • Question: How To Deploy War Or Java Applications In Apache?
    Answer :

    I am afraid, Apache is a Web Server and Java based application deployment is not possible with it. However, you can integrate Java application server like WebLogic, WebSphere, JBoss where you can deploy war, ear files.

  • Question: How To Disable Trace Http Request?
    Answer :

    Add the following in httpd.conf file and restart the instance

    TraceEnable off

  • Question: How To Ensure Apache Listen On Only One Ip Address On The Server?
    Answer :

    This is often needed when you have multiple IPs on the server. In order to ensure Apache listen only on specified IP then you need to explicitly mention IP and port in Listen directive.



  • Question: How To Ensure Apache Process Run With Non-root/nobody User?
    Answer :

    This is doable by adding User & Group directive in httpd.conf file

    • User apache
    • Group apache

    Above configuration example will ensure it starts with “apache” user. You must ensure user exist on the server before configuring it.

  • Question: How To Ensure Web Server Is Getting Started After Server Reboot?
    Answer :

    If running Linux, then you can put a script in /etc/init.d/ and enable to start on boot using chkconfig command

    Let’s say you create a file called apache and put under /etc/init.d

    chkconfig –add apache

    chkconfig apache on

    if on Windows, then ensure startup type is selected “Automatic”

  • Question: How To Find Httpd.conf File If You Don’t Know Installation Location?
    Answer :

    In Linux, you can use find command.

    Let’s assume, you know it must be in /apps file system then you can use the following command.

    find /apps -name httpd.conf

    But if you are not sure on which file system then you can do find on / file system but keep it in mind it may take a long time based on the overall file system size.

    find / -name httpd.conf

  • Question: How To Get Support For Apache Web Server If Something Wrong?
    Answer :

    Apache is an Open Source web server so there is no enterprise level support however, you can raise a bug report or ask a question on Stack Overflow.

  • Question: How To Hide Server Version Details In Http Response Header?
    Answer :

    Add the following in httpd.conf file and restart the web server

    ServerTokens Prod
    ServerSignature Off

    This will hide the version and show Server as “Apache” Only.

  • Question: How To Install Apache Web Server?
    Answer :

    There are three possible ways to get this installed.

    Using source code – you can download the source and compile it.

    YUM repository – if your server is connected to the Internet or have internal repository then you can use yum to install it.

    yum install httpd

    RPM – You can download the necessary RPM package and use rpm command.

    rpm -ivh packagename.rpm

  • Question: How To Know If Web Server Running?
    Answer :

    There are multiple ways to find this.

    1. Login to web server and grep for “httpd” process

    ps -ef |grep httpd

    1. Check for any alert in your monitoring dashboard.
    2. Check if your apache IP:port is accessible in the browser

    Ex: http://yourapacheserver.com

    1. Check if configured IP and port is listening on the server with netstat

    netstat -anlp |grep 80

  • Question: How To Perform Apache Performance Benchmark?
    Answer :

    You can use a tool like ApacheBench, SIEGE to perform the load test on web servers including Apache. Another option to perform stress test online to see the overall how web application performs under load.

  • Question: How To Put Log Level In Debug Mode?
    Answer :

    Often needed when you are troubleshooting the issue and wish to capture more details. You can change the logging level to debug by ensuring the following in httpd.conf file.

    LogLevel debug

  • Question: How To Secure Website Hosted On Apache Web Server?
    Answer :

    There are multiple ways to secure the Apache web server including the following.

    • Implementing SSL
    • Integrating with WAF (Web Application Firewall) like ModSecurity, etc.
    • Using cloud-based security provider
  • Question: How To Troubleshoot Port Conflict Issue?
    Answer :

    netstat would be useful to troubleshoot the port conflict issue. If running multiple instances on a single server then it would be recommended to have absolute IP:Port configured in Listen directive.

  • Question: How To Verify Httpd.conf File To Ensure No Configuration Syntax Error?
    Answer :

    httpd –t will help you to verify the syntax.

    [root@lab httpd]# /usr/sbin/httpd -t

    Syntax OK

    [root@lab httpd]#

    Alternatively, you may use apachectl command as well.

    [root@lab ~]# /usr/sbin/apachectl configtest

    Syntax OK

    [root@lab ~]#

  • Question: How Would You Kill The Apache Process If Graceful Stop Doesn’t Work?
    Answer :

    If running on Linux, then can use kill command.

    Find out the PID of Apache by using ps -ef |grep http

    Then kill it

    kill $PIDNUMBER

    if normal kill doesn’t work then try kill -9

    kill -9 $PIDNUMBER

    if on Windows, then end the apache task from Task Manager.

  • Question: What Are The Different Flavor Of Apache Web Server You Know?
    Answer :

    IBM HTTP Server – known as IHS and often used with IBM WebSphere Application Server

    Oracle HTTP Server- known as OHS often used with Oracle Weblogic server

  • Question: What Are The Log Files Generated By Apache?
    Answer :

    There are two popular log files created;

    access.log – all request details with the status code.

    error.log – capture all the errors within apache or connecting in backend.

  • Question: What Are The Log Level Available In Apache?
    Answer :

    The default configuration is set to “warn” however, the following is possible too.

    • debug
    • info
    • warn
    • notice
    • crit
    • alarm
    • emerg
    • error
  • Question: What Are The Web Servers You’ve Worked On Along With Apache?
    Answer :

    Again, you better tell the truth but to make you aware there are many web servers in the market including the following.

    • Nginx
    • Microsoft IIS
    • LiteSpeed
    • GWS
  • Question: What Does 200, 403 & 503 Http Error Code Mean?
    Answer :

    • 200 – content found and served OK
    • 403 – tried to access restricted file/folder
    • 503 – server is too busy to serve the request and in another word – service unavailable.
  • Question: What Is A Difference Between Apache And Nginx Web Server?
    Answer :

    Both are categorized as a Web Server and here are some of the main differences.

    • Nginx is event-based web server where Apache is process based
    • Nginx is known for better performance than Apache
    • Apache supports wide range of OS where Nginx doesn’t support OpenVMS and IBMi
    • Apache has large number of modules integration with backend application server where Nginx is still catching up
    • Nginx is lightweight and capturing the market share rapidly. If you are new to Nginx then you may be interested to check out my articles on Nginx.
  • Question: What Is Documentroot?
    Answer :

    DocumentRoot directive is the configuration where you can specify the folder location from where the static files will be served. It’s also called as Web Root.

    Default DocumentRoot location is /var/www/html

  • Question: What Is The Default Port For Http And Https?
    Answer :

    The default port for HTTP is 80 and HTTPS 443. Checkout default ports for other applications listed here.

  • Question: What Is Virtual Hosting?
    Answer :

    Virtual Hosting in Apache allows you to host multiple websites on a single instance. You can either create IP based or Name based in virtual hosting.

  • Question: What Module Is Needed To Connect To Websphere?
    Answer :

    mod_was_ap22_http.so must be added in httpd.conf file to integrate with IBM WAS.

  • Question: What Tool Do You Use For Log Analysis?
    Answer :

    You got to speak the truth but to given you an idea you can use GoAccess, SumoLogic or few mentioned here.

  • Question: What’s Difference Between Apache Web Server And Apache Tomcat?
    Answer :

    Apache Web is HTTP server to serve static contents where Tomcat is servlet container to deploy JSP files.

    You can always integrate Apache HTTP with Tomcat, however, based on the requirement you need to choose either one. If you need proper web server then Apache HTTP else Tomcat for JSP-Servlet Container.

  • Question: What’s The Weblogic Module Name?
    Answer :


  • Question: Where Is Apache Web Server Located In Data Center Location?
    Answer :

    You can explain based on your experience, however, typically for Internet-facing applications it would be in Internet DMZ network and for intranet, core network.
    But again this will differ based on application/organization.

  • Question: Which Module Is Required To Enable Ssl?
    Answer :

    The mod_ssl module must be uncommented prior to SSL implementation.

    LoadModule auth_basic_module modules/mod_ssl.so

  • Question: Which Module Is Required To Have Redirection Possible?
    Answer :

    mod_rewrite is responsible for the redirection and this must be uncommented in httpd.conf file.

    LoadModule rewrite_module modules/mod_rewrite.so

  • Apache Web Server (Level 2) Questions and Answers for Interview

    Preparing for Apache Web Server (Level 2) job interview and whether you’re experienced or fresher & don’t know what kind of questions will be asked in Apache Web Server (Level 2) interview, then go through the above 100+ Top Apache Web Server (Level 2) Interview Questions and Answers to crack your job interview.

    70+ TOP Apache Tomcat Interview Questions and Answers [UPDATED]

  • Question: What Is Tomcat?

    Answer :

    Tomcat is a Java Servlet container and web server from Jakarta project of Apache software foundation. A web server sends web pages as response to the requests sent by the browser client. In addition to the static web pages, dynamic web pages are also sent to the web browsers by the web server. Tomcat is sophisticated in this respect, as it provides both Servlet and JSP technologies. Tomcat provides a good choice as a web server for many web applications and also a free Servlet and JSP engine. Tomcat can be used standalone as well as behind other web servers such as Apache httpd.

  • Question: What Is Webservers? Why It Is Used?

    Answer :

    Transaction with HTTP request and HTTP response is called webserver.

    Using the internet listening the HTTP request and providing the HTTP response is also called webserver.It gives only html output.It will not process business logic .They can provide Http server.They are static.

  • Question: What Is Different Between Webserver And Application Server?

    Answer :

    The basic difference between a web server and an application server is Webserver can execute only web applications i,e servlets and JSPs and has only a single container known as Web container which is used to interpret/execute web applications. Application server can execute Enterprise application, i,e (servlets, jsps, and EJBs)

    it is having two containers:

    1. Web Container(for interpreting/executing servlets and jsps)
    2. EJB container(for executing EJBs).

    it can perform operations like load balancing , transaction demarcation etc.

  • Question: How Web Server Handles Multiple Requests For Same Action Class(struts) Concurrently?

    Answer :

    Struts or any webserver makes new thread for each new request. so multiple request is served with new request object.

  • Question: Explain What Is Tomcat Coyote?

    Answer :

    Tom coyote is an HTTP connector based on HTTP/ 1.1 specification which receives and transport web requests to the Tomcat engine by listening to a TCP/IP port and sent request back to the requesting client.

  • Question: Explain What Is Jasper?

    Answer :

    • Jasper is a Tomcat JSP engine
    • It parses JSP files to compile them into JAVA code as servlets
    • At runtime, Jasper allows to automatically detect JSP file changes and recompile them
  • Question: Explain When To Use Ssl With Tomcat?

    Answer :

    You would use Tomcat to handle connection, when you are running Tomcat as a stand-alone web server.

  • Question: Explain How Running Tomcat As A Windows Service Provides Benefits?

    Answer :

    Running Tomcat as a windows service provides benefits like:

    • Automatic startup: It is crucial for environment where you may want to remotely re-start a system after maintenance
    • Server startup without active user login: Tomcat is run oftenly on blade servers that may not even have an active monitor attached to them. Windows services can be started without an active user
    • Security: Tomcat under window service enables you to run it under a special system account, which is protected from the rest of the user accounts
  • Question: How Do I Can Change The Default Home Page Loaded By Tomcat?

    Answer :

    We can easily override home page via adding welcome-file-list in application $TOMCAT_HOME/webapps//WEB-INF /web.xml file or by editing in container $TOMCAT_HOME/conf/web.xml

    In $TOMCAT_HOME/conf/web.xml, it may look like this: 




    Request URI refers to a directory, the default servlet looks for a “welcome file” within that directory in following order: index.html, index.htm and index.jsp

    If none of these files are found, server renders 404 error.

  • Question: Explain How Servlet Life Cycles?

    Answer :

    The life-cycle of a typical servlet running on Tomcat:

    • Tom-cat receives a request from a client through one of its connectors
    • For processing, this request Tomcat maps this request to appropriate
    • Once the request has been directed to the appropriate servlet, Tomcat verifies that servlet class has been loaded. If it is not than Tomcat wraps the servlet into Java Bytecode, that is executable by the JVM and forms an instance of the servlet
    • Tomcat initiates the servlet by calling its init The servlet contains code that is able to screen Tomcat configuration files and act accordingly, as well as declare any resources it might require
    • Once the servlet has been started, Tomcat can call the servlet’s service method to proceed the request
    • Tomcat and the servlet can co-ordinate or communicate through the use of listener classes during the servlet’s lifecycle, which tracks the servlet for a variety of state changes.
    • To remove the servlet, Tomcat calls the servlets destroy method.
  • Question: What Is Apache Tomcat?

    Answer :

    Apache Tomcat is an open-source web server and Servlet/JSP container developed by the Apache Software Foundation. Tomcat implements several Java EE specifications including Java Servlet, Java Server Pages (JSP), Java EL, and WebSocket, and provides a “pure Java” HTTP web server environment for Java code to run in.

  • Question: How Do You Create Multiple Virtual Hosts?

    Answer :

    If you want tomcat to accept requests for different hosts e.g. www.myhostname.com then you must

    • Create ${catalina.home}/www/appBase , ${catalina.home}/www/deploy, and ${catalina.home}/conf/Catalina/www.myhostname.com
    • Add a host entry in the server.xml file
    • Create the the following file under conf/Catalina/www.myhostname.com/ROOT.xml
    • Add any parameters specific to this hosts webapp to this context file
    • Put your war file in ${catalina.home}/www/deploy
    • When tomcat starts, it finds the host entry, then looks for any context files and will start any apps with a context.
  • Question: Explain When You Can Use . And When You Can Use []?

    Answer :

    If you are running a bean property, use the .operator, and if you are executing a map value or an array index, it is preferred to use the [] operator. Although you can use these operators interchangeably.

  • Question: Suppose When We Are Starting Startup.bat File Of Tomcat Server It Is Not Started. Dos Window Appears For A Second Only. What We Need Do?

    Answer :

    Your set up might have been not done well.

    Make sure you have added tomcat root directory path in the CATALINA_HOME environment variable and added the bin path in the path variable.

  • Question: What Is Default Session Time Out In Tomcat?

    Answer :

    The default session timeout 30 minutes in tomcat and can change in $TOMCAT_HOME/conf/web.xml via modify below entry




  • Question: Explain What Is Tomcat Valve?

    Answer :

    A tomcat valve- a new technology is introduced with Tomcat 4 which enables you to link an instance of a Java class with a specific Catalina container.

  • Question: Mention What Are The Connectors Used In Tomcat?

    Answer :

    In Tomcat, two types of connectors are used:

    1. HTTP Connectors: It has many attributes that can be changed to determine exactly how it works and access functions such as redirects and proxy forwarding
    2. AJP Connectors: It works in the same manner as HTTP connectors, but they practice the AJP protocol in place of HTTP. AJP connectors are commonly implemented in Tomcat through the plug-in technology mod_jk.
  • Question: How To Communicate Between Two Web Servers In Two Diff Systems?

    Answer :

    By using plug module .

  • Question: Explain Directory Structure Of Tomcat?

    Answer :

    Directory structure of Tomcat are:

    bin – contain startup, shutdown, and other scripts (*.sh for UNIX and *.bat for Windows systems) and some jar files also there.

    conf – Server configuration files (including server.xml) and related DTDs. The most important file in here is server.xml. It is the main configuration file for the container.

    lib – contains JARs those are used by container and Servlet and JSP application programming interfaces (APIs).

    logs – Log and output files.

    webapps – deployed web applications reside in it .

    work – Temporary working directories for web applications and mostly used during in JSP compilation where JSP is converted to a Java servlet.

    temp – Directory used by the JVM for temporary files .

  • Question: Mention With How Many Valves Does Tomcat Configured With?

    Answer :

    Four types of valves Tomcat is configured with:

    • Access Log
    • Remote Address Filter
    • Remote Host Filter
    • Request Dumper
  • Question: Mention What Is The Output Of Select * From Tab?

    Answer :

    It displays the default tables in the database

  • Question: Can I Set Java System Properties Differently For Each Webapp?

    Answer :

    No. If you can edit Tomcat’s startup scripts, you can add “-D” options to Java. But there is no way to add such properties in web.xml or the webapp’s context.

  • Question: How To We Can Change Tomcat Default Port?

    Answer :

    8080 is the default HTTP port that Tomcat attempts to bind to at startup.  To change this, we need to change port in $ TOMCAT_HOME /conf/server.xml, in that we can search 8080 and after getting below statement

    <Connector port=”8080″ protocol=”HTTP/1.1″  connectionTimeout=”20000″  redirectPort=”8443″ />

    We can change 8080 to other port like 8081, we need to restart tomcat to take effect. We required changes in URL as http://localhost:8081/.

  • Question: Explain The Concepts Of Tomcat Servlet Container.?

    Answer :

    • Tomcat Servlet Container is a servlet container. The servlets runs in servlet container.
    • The implementation of Java Servlet and the Java Server Pages is performed by this container.
    • Provides HTTP web server environment in order to run Java code.
    • Reduces garbage collection
    • Native Windows and Unix wrappers for platform integration
  • Question: Explain What Does The Mac Stands For?

    Answer :

    MAC means Medium Access Control

  • Apache Tomcat Questions and Answers for Interview

    Preparing for Apache Tomcat job interview and whether you’re experienced or fresher & don’t know what kind of questions will be asked in Apache Tomcat interview, then go through the above 70+ Top Apache Tomcat Interview Questions and Answers to crack your job interview.

    50+ TOP Apache Tapestry Interview Questions and Answers [UPDATED]

  • Question: Is There A Wysiwyg Editor For Tapestry, Or An Ide Plugin?

    Answer :

    Currently, no WYSIWYG editor is available for Tapestry; however, the design of Tapestry allows existing editors to work reasonably well (Tapestry additions to the HTML markup are virtually invisible to a WYSIWYG editor).Spindle is a Tapestry plugin for the excellent open-source Eclipse IDE. It adds wizards and editors for creating Tapestry applications, pages and components.

  • Question: How Do I Integrate A Tapestry Application With J2ee Declarative Security/jaas?

    Answer :

    In web.xml:

    add an additional servlet mapping for your tapestry application to /admin, and add the following:

    1. <security-constraint>
    2.  <web-resource-collection>
    3.   <url-pattern>/admin/*</url-pattern>
    4.  </web-resource-collection>
    5.  <auth-constraint>
    6.    <role-name>ADMIN</role-name>
    7.  </auth-constraint>
    8. </security-constraint>

    In your base class for protected pages:

    public void validate(IRequestCycle cycle) throws RequestCycleException {
      boolean isAdmin = getRequestCycle().getRequestContext().getRequest().isUserInRole(“ADMIN”);
      if (!isAdmin) {
        // not in right role
        throw new PageRedirectException…….


    you can have a number of mappings for the same app-servlet to different URIs, that way you can rely a bit more on the declarative security.

  • Question: How Does Tapestry Compare To Other Frameworks?

    Answer :

    Tapestry is very much unlike most other frameworks in that it doesn’t use code generation; instead it uses a true component object model based on JavaBeans properties and strong specifications. This gives Tapestry a huge amount of flexibility and enables dynamic runtime inspection of the application with the Tapestry Inspector (a mini-application that can be built into any Tapestry application).

  • Question: Is Apache Tapestry Free/open Source?

    Answer :

    Yes. Tapestry is open source and free. 

    It is licensed under the Apache Software License, which allows it to be used even inside proprietary software.

  • Question: Does Tapestry Use Jsp Tag Libraries?

    Answer :

    • No. Tapestry does not use JSP Tag library.
    • Tapestry builds on the Servlet API, but does not use JSP anyway.
    • It uses it own HTML template format and its own rendering engine.
  • Question: What Is Apache Tapestry?

    Answer :

    • A component-based view framework.
    • Classes are written as POJOs and byte-code transformed at run time
    • Configured with annotations and naming conventions rather than XML
    • Compared to JSPs, enforces a clear separation of HTML markup and Java code.
    • HTML templates are directly previewable by web designers
    • Changed component classes are live-reloaded into running application for faster development.
    • Uses the Post/Redirect/Get navigation pattern for form submission.
  • Question: I Have A Form With A Submit Button. On The Form And The Submit Button Are Two Separate Listeners. Which Is Invoked First?

    Answer :

    The button’s listener should get invoked when the form encounters your button during the rewind. the form’s submitListener should get invoked after the form has completed its rewind, and thus after all other listeners have been invoked. note – this can mean that the listener for a button can be invoked BEFORE the form has ’submitted’ all its values – it depends where your input fields are relative to your button.

  • Question: How Do I Make A Link Popup A New Window?

    Answer :

    Use the contrib:PopupLink component.

  • Question: Can I Use The Same Component Multiple Times In One Template?

    Answer :

    No – but you can copy the definition of a component pretty easily.

    <component id=”valueInsert” type=”Insert” >
       <binding name=”value” expression=”getValueAt( rowIndex, columnIndex )” />

    <component id=”valueInsert1″ copy-of=”valueInsert”/>
    <component id=”valueInsert2″ copy-of=”valueInsert”/>
    <component id=”valueInsert3″ copy-of=”valueInsert”/>
    <component id=”valueInsert4″ copy-of=”valueInsert”/>

  • Question: How Is The Performance Of Tapestry?

    Answer :

    My own testing, documented in the Sept. 2001 issue of the Java Report, agrees with other testing (documented in the Tapestry discussion forums): Although straight JSPs have a slight edge in demo applications, in real applications with a database or application server backend, the performance curves for equivalent Tapestry and JSP applications are identical. Don’t think about the performance of Tapestry; think about the performance of your Java developers.

  • Question: Does Tapestry Work With Other Other Application Servers Besides Jboss?

    Answer :

    Of course! JBoss is free and convienient for the turn-key demonstrations. You can download Tapestry and JBoss and have a real J2EE application running in about a minute! The scripts that configure JBoss are sensitive to the particular release of JBoss, it must be release 3.0.6. However, Tapestry applications are 100% container agnostic … Tapestry doesn’t care what servlet container it is used with and does not even require an EJB container.

  • Question: Is Tapestry A Jsp Tag Library?

    Answer :

    Tapestry is not a JSP tag library; Tapestry builds on the servlet API, but doesn’t use JSPs in any way. It uses it own HTML template format and its own rendering engine. Starting with release 3.0, Tapestry includes a simple JSP tag library to allow JSP pages to create links to Tapestry pages.

  • Question: How Do I Stream A File To The User From Tapestry?

    Answer :

    Make a method like the following a a listener, such as from a DirectLink or whatever.

    (The Document is just a class that holds the file information you want to send to the user.)

    public void downloadAction(IRequestCycle cycle)
            HttpServletResponse response =

            byte[] data = new byte[1024];
            FileInputStream in = document.getFileInputstream();

              “inline; filename=” +
            response.setContentLength(new Long(document.getSize()).intValue());
            ServletOutputStream out = response.getOutputStream();

            while (in.read(data) > -1)
        catch (IOException e)

  • Question: How To Alter The Url To Point To The Correct Page?

    Answer :

    You would need to throw a RedirectException with the new URL; this sends an HTTP redirect to the client.

  • Question: What Does It Cost?

    Answer :

    Tapestry is open source and free. It is licensed under the Apache Software License, which allows it to be used even inside proprietary software.

  • Question: How Do We Write Components In Apache Tapestry?

    Answer :

    Retrieving bound properties : When writting a component, you often require various properties to be supplied by the component user. At some point during rendering, you will want to use the value of this property.

    You can do this by accessing the Binding. Assume we have a component with one property called ‘values’. Our component will use this list in its preRenderCommponent() method to setup some model, for use elsewhere.

    …. if(getValues() == null) {
      IBinding binding = getBindings(“values”); if(binding.getObject() == null) {
          throw new RequestCycleException(“The value for ‘values’ cannot be null”, this);
      } setValues((List)values.getObject());

    The binding itself will ensure that the object value is the correct type (assuming of course, it’s been setup right).

    Performing Lazy Instantiation of state based upon component properties : In some cases, the output of a component may be based upon the state of some other property of the same component. For example, imagine a form where the user can choose the type of product to view. When they choose a product, the form makes a query to the database for products matching this type, and reshows the list on the same page. (the list would be included outside of the form element itself).

    Lets assume that the page object exposes it’s products via a getProductModel() – which is an instance of IPropertySelectionModel.

    We will also assume that the remainder of the page has the other components necessary to render correct HTML, using the value supplied by the getProductModel() result.

    Here, it is helpful to know when in the rendering process you can rely on the value of selectedProduct to be set correctly, so that you can instantiate a ProductModel based on the provided value, for use in the form rendering. The best place to setup state is in the preRenderComponent() method. This is called by Tapestry just before it renders any component, but AFTER it has set component properties. So, we might write:

    protected void preRenderComponent() {
      String selected = getSelectedProduct();
      List products = getMatchingProducts(selectedProduct);
      productModel = new ProductModel(products);
      .. other initialization code …

  • Question: What’s The Lifecycle Of A Form Submit?

    Answer :

    Events will trigger in the following order:


    The form “rewind” cycle is nothing more than a render cycle where the output is buffered and scrapped rather than written to the servlet output stream. The second pageBeginRender() is triggered during the actual page rendering. You can use requestCycle.isRewinding() to distinguish between these two render cycles.

  • Question: Why Do We Need @script In Apache Tapestry?

    Answer :

    The script framework is an effective means to bundle scripts in components. It provides scripts with the advantages of components. It can now be reused like a component and not have to worry about renaming field names or the wiring between the fields and the scripts. You just declare the component and you are good to go. It certainly is another layer of abstraction that one will have to learn but once you have learned it, it is very powerful. And honestly there is not much to it.

    The script framework is mandated by the fact that form element/field names are automatically generated by the framework. And so you write your script in XML and use variables for these names and let the framework provide the correct names during runtime. Going further, you may also ask the framework to provide other objects that would help in creating your script. For example…

    <input-symbol key=”select”

    This defines an input variable “select” of type “org.apache.tapestry.form.PropertySelection”. All such variables/symbols passed in to the script is stored in a symbol map. And now you can use the form select list name by using an ant style syntax like ${select.name}. The expression within “${}” is an OGNL expression and is evaluated with respect to the symbol map. You may also define your own symbols/variables using <let…> like…

    <let key=”formObj”>
    <let key=”selectObj”>

    These variables/symbols are stored in the symbol map also. So now if you want to set the value of the form select list all you do is say ${formObj}.${selectObj}.value = ‘whatever’; this would be equivalent to document.myForm.mySelect.value = ‘whatever’; where myForm is the form name and mySelect is the select list name.

    <input-symbol…>s are like method parameters and <let…>s are like instance variables. Typically you would pass values to the <input-symbol…>s via the Script component like…

    <component id=”myScript” type=”Script”>
        <static-binding name=”script” value=”ScriptSpecificationName.script”/>
        <binding name=”select” expression=”components.somePropertySelection”/>

    The actual scripts are defined in one of the two sections of the script specification, <body…> or <initialization…>, depending on when you want the script to execute. If you want the script to execute on load of the page, then you define it in the <initialization…>, if you want it to execute on any other event, define it in the <body…> section of the specification. For example…


    1. <body>
    2.     function onChangeList(listObj)
    3.     {
    4.         alert(listObj.value);
    5.     }
    6. </body>
    7. <initialization>
    8.     ${selectObj}.onchange = function(e)
    9.     {
    10.         onChangeList(${selectObj});
    11.     }
    12. </initialization>

    As you can see in the rendered page all scripts are aggregated at the top of the page body, there are no more scripts all over the page. Even event handlers are attached to form objects in the initialization block.

    One more thing to remember, scripts being components, and components by nature being independent of its environment, will render the script in the page once for every ocurrance of the component. If you want the body of the script to be rendered only once no matter how many times the component is used, just wrap the body in a <unique> tag like…

        function onChangeList(listObj)

  • Question: How To Get A File From Client Input To Server End In Apache Tapestry?

    Answer :

    Make a method like the following a a listener, such as from a DirectLink or whatever.

    (The Document is just a class that holds the file information you want to send to the user.)

    1. public void downloadAction(IRequestCycle cycle)
    2. {
    3.     try
    4.     {
    5.         HttpServletResponse response =
    6.         cycle.getRequestContext().getResponse();
    7.         byte[] data = new byte[1024];
    8.         FileInputStream in = document.getFileInputstream();
    9.         response.setHeader(“Content-disposition”,
    10.           “inline; filename=” +
    11.            document.getFileName());
    12.         response.setContentType(document.getMimeType());
    13.         response.setContentLength(new Long(document.getSize()).intValue());
    14.         ServletOutputStream out = response.getOutputStream();
    15.         while (in.read(data) > -1)
    16.         {
    17.             out.write(data);
    18.         }
    19.         in.close();
    20.         response.flushBuffer();
    21.     }
    22.     catch (IOException e)
    23.     {
    24.         e.printStackTrace();
    25.     }
    26. }
  • Question: How Should Do Page Navigation In Apache Tapestry?

    Answer :

    Usage page properties:

    <page-specification class=”Welcome.Action”>
            <property name=”success” value=”Home” />
            <property name=”error” value=”Error” />

    <page-specification class=”Welcome.Action”>
            <property name=”success” value=”Home2″ />
            <property name=”error” value=”Error2″ />

    public void submitListener(IRequestCycle cycle)
        if (success)
        if (error)

    So on success, it will be redirected to Home2 and on error it will be redirected to Error2 page.

  • Question: I Have To Restart My Application To Pick Up Changes To Specifications And Templates, How Can I Avoid This?

    Answer :

    Start your servlet container with the JVM system parameter org.apache.tapestry.disable-caching set to true, i.e., -Dorg.apache.tapestry.disable-caching=true. 

    Tapestry will discard cached specifications and templates after each request. You application will run a bit slower, but changes to templates and specifications will show up immediately. This also tests that you are persistent server-side state correctly. 

  • Apache Tapestry Questions and Answers for Interview

    Preparing for Apache Tapestry job interview and whether you’re experienced or fresher & don’t know what kind of questions will be asked in Apache Tapestry interview, then go through the above 50+ Top Apache Tapestry Interview Questions and Answers to crack your job interview.

    70+ TOP Apache Tajo Interview Questions and Answers [UPDATED]

  • Question: Explain Tajo Configuration Files?

    Answer :

    Tajo’s configuration is based on Hadoop’s configuration system.

    Tajo uses two config files:

    catalog-site.xml- configuration for the catalog server.

    tajo-site.xml- configuration for other tajo modules. Tajo has a variety of internal configs. If you don’t set some config explicitly, the default config will be used for for that config. Tajo is designed to use only a few of configs in usual cases. You may not be concerned with the configuration.

    In default, there is no tajo-site.xml in ${TAJO}/conf directory. If you set some configs, first copy $TAJO_HOME/conf/tajo-site.xml.templete to tajo-site.xml. Then, add the configs to your tajo-site.

  • Question: How To Create Index Statement In Apache Tajo?

    Answer :

    The CREATE INDEX statement is used to create indexes in tables. Index is used for fast retrieval of data. Current version supports index for only plain TEXT formats stored on HDFS.

    CREATE INDEX [ name ] ON table_name ( { column_name | ( expression ) }

    create index student_index on mytable(id);

  • Question: What Are The Different Data Formats Supported By Apache Tajo?

    Answer :

    • Text
    • JSON
    • Parquet
    • RCFile
    • SequenceFile
    • ORC
  • Question: Mention Some Basic Tajo Shell Commands?

    Answer :

    Start server

    $ bin/start-tajo.sh

    Start Shell

    $ bin/tsql

    List Database

    default> l

    List out Built-in Functions

    default> df

    Describe Function: df function name – This query returns the complete description of the given function.

    default> df sqrt

    Quit Terminal

    default> q

    Cluster Info

    default&> admin -cluster

    Show master

    default> admin -showmasters

  • Question: Mention The Salient Features Of Apache Tajo ?

    Answer :

    Some salient feaures of Tajo are:

    • Superior scalability and optimized performance
    • Low latency
    • User-defined functions
    • Row/columnar storage processing framework.
    • Compatibility with HiveQL and Hive MetaStore
    • Simple data flow and easy maintenance.
  • Question: Explain About Tablespace?

    Answer :

    The locations in the storage system are defined by Tablespace. It is supported for only internal tables. Tablespaces are accessed by their names. Each tablespace can use a different storage type. If the tablespace is not specified then, Tajo uses the default tablespace in the root directory. Tajo’s internal table records can be accessed from another table only. It can be configured with tablespace.


       [(column_list)] [TABLESPACE tablespace_name]

       [using [with ( = , …)]] [AS ]

  • Question: What Are The Window Functions Provided By Apache Tajo?

    Answer :

    The functions that execute on a set of rows and return a single value for each row are Window functions. The Window function in a query, defines the window using the OVER() clause.

    The OVER() clause has the following capabilities:

    • Defines window partitions to form groups of rows. (PARTITION BY clause)
    • Orders rows within a partition. (ORDER BY clause)

    Some of the window functions are:

    • rank()
    • row_num()
    • lead(value[, offset integer[, default any]])
    • lag(value[, offset integer[, default any]])
    • first_value(value)
    • last_value(value)
  • Question: How Can We Launch A Tajo Cluster?

    Answer :

    To launch the tajo master, execute start-tajo.sh.

    $ $TAJO HOME/sbin/start-tajo.sh

    After then, you can use tajo-cli to access the command line interface of Tajo. If you want to how to use tsql, read Tajo Interactive Shell document.

    $ $TAJO HOME/bin/tsql

  • Question: How Tables Are Managed In Apache Tajo?

    Answer :

    The logical view of the data source is defined as table. The table consists of various properties like logical schema, partitions, URL etc. A Tajo table can be a directory in HDFS, a single file, one HBase table, or a RDBMS table.

    The types of tables supported by Apache Tajo are:

    External table: External table needs the location property when the table is created. For instance, if the data is already there as Text/JSON files or HBase table, it can be registered as Tajo external table. The following query is an example of external table creation.

    create external table sample(col1 int,col2 text,col3 int) 

    location ‘hdfs://path/to/table’;

    Internal table: A Internal table is also called an Managed Table. It is created in a pre-defined physical location called the Tablespace.

    create table table1(col1 int,col2 text);

    By default, Tajo uses “tajo.warehouse.directory” located in “conf/tajo-site.xml” . Tablespace configuration is used to assign new location for the table.

  • Question: How To Drop Database In Apache Tajo?

    Answer :

    The syntax used to drop a database is –


    Ex: test> c default

  • Question: Explain Abount Postgresql Storage Handler?

    Answer :

    Tajo supports PostgreSQL storage handler. It enables user queries to access database objects in PostgreSQL. It is the default storage handler in Tajo so you can easily configure it.


    “spaces”: {

    “postgre”: {

    “uri”: “jdbc:postgresql://hostname:port/database1”

    “configs”: {

    “mapped_database”: “sampledb”

    “connection_properties”: {

    “user”:“tajo”, “password”: “pwd”






    Here, “database1” refers to the postgreSQL database which is mapped to the database “sampledb” in Tajo.

  • Question: What Is Apache Tajo?

    Answer :

    Apache Tajo is a relational and distributed data processing framework. It is designed for low latency and scalable ad-hoc query analysis.

    • Tajo supports standard SQL and various data formats. Most of the Tajo queries can be executed without any modification.
    • Tajo has fault-tolerance through a restart mechanism for failed tasks and extensible query rewrite engine.
    • Tajo performs the necessary ETL (Extract Transform and Load process) operations to summarize large datasets stored on HDFS. It is an alternative choice to Hive/Pig.
  • Question: What Are The Data Formats Supported By Apache Tajo?

    Answer :

    Apache Tajo supports the following data formats:

    • JSON
    • Text file(CSV)
    • Parquet
    • Sequence File
    • AVRO
    • Protocol Buffer
    • Apache Orc
  • Question: How To Create Database Statement In Apache Tajo?

    Answer :

    The statement used to create a database in Tajo is Create Database and the syntax for the statement is:


    Ex: default> create database if not exists test;

  • Question: What Is Having Clause In Apache Tajo?

    Answer :

    The HAVING clause enables you to specify conditions that filter which group results appear in the final results. The WHERE clause places conditions on the selected columns, whereas the HAVING clause places conditions on the groups created by the GROUP BY clause.

    SELECT column1, column2 FROM table1 

         GROUP BY column HAVING [ conditions ]

     select age from mytable group by age having sum(mark) > 200;

  • Question: Explain Different Queries Performed By Apache Tajo?

    Answer :

    Predicates: To evaluate the true/false values of the UNKNOWN, an expression used is known as Predication. For the search condition of WHERE clause and HAVING clause, and constructs that require a Boolean value, predicate is used.

    Explain: To obtain a query execution plan with a logical and global plan execution of a statement, Explain is used.

    Join: SQL joins are used to combine rows from two or more tables.

    The following are the different types of SQL Joins:

    • Inner join
    • Cross join
    • Self join
    • Natural join
  • Question: How To Add Column In Apache Tajo?

    Answer :

    To insert new column in the “students” table, type the following syntax –

    Alter table ADD COLUMN

     alter table students add column grade text;

  • Question: How To Set Property In Apache Tajo?

    Answer :

    This property is used to change the table’s property.

    ALTER TABLE students SET PROPERTY ‘compression.type’ = ‘RECORD’,

    ‘compression.codec’ = ‘org.apache.hadoop.io.compress.Snappy Codec’ ;

  • Question: What Is Distinct Clause In Apache Tajo?

    Answer :

    A table column may contain duplicate values. The DISTINCT keyword can be used to return only distinct (different) values.

    SELECT DISTINCT column1,column2 FROM table name;

     select distinct age from mytable;

  • Question: Explain About Tajo Worker Configuration?

    Answer :

    Worker Heap Memory Size: The environment variable TAJO_WORKER_HEAPSIZE in conf/tajo-env.sh allow Tajo Worker to use the specified heap memory size. If you want to adjust heap memory size, set TAJO_WORKER_HEAPSIZE variable in conf/tajo-env.

    sh with a proper size as follows:


    The default size is 1000 (1GB).

    Temporary Data Directory: TajoWorker stores temporary data on local file system due to out-of-core algorithms. It is possible to specify one or more temporary data directories where temporary data will be stored.

    Maximum number of parallel running tasks for each worker: Each worker can execute multiple tasks at a time. Tajo allows users to specify the maximum number of parallel running tasks for each worker.

  • Question: Explain About Catalog Configuration?

    Answer :

    If you want to customize the catalog service, copy $TAJO_HOME/conf/catalog-site.xml.template to catalog-site.xml. Then, add the following configs to catalog-site.xml. Note that the default configs are enough to launch Tajo cluster in most cases.

    tajo.catalog.master.addr – If you want to launch a Tajo cluster in distributed mode, you must specify this address. For more detail information, see Default Ports.

    tajo.catalog.store.class – If you want to change the persistent storage of the catalog server, specify the class name. Its default value is tajo.catalog.store.DerbyStore. In the current version, Tajo provides three persistent storage classes as follows:

    tajo.catalog.store.DerbyStore – this storage class uses Apache Derby.

    tajo.catalog.store.MySQLStore – this storage class uses MySQL.

    tajo.catalog.store.MemStore – this is the in-memory storage. It is only used in unit tests to shorten the duration of unit tests.

  • Question: What Are The Storage Supported By Tajo?

    Answer :

    Tajo supports the following storage formats:

    • HDFS
    • JDBC
    • Amazon S3
    • Apache HBase
    • Elasticsearch
  • Question: What Are The Benefits Of Apache Tajo?

    Answer :

    Apache Tajo offers the following benefits:

    • Easy to use
    • Simplified architecture
    • Cost-based query optimization
    • Vectorized query execution plan
    • Fast delivery
    • Simple I/O mechanism and supports various type of storage.
    • Fault tolerance
  • Question: How To Insert Records In Apache Tajo?

    Answer :

    To insert records in the ‘test’ table, type the following query.

    db sample> insert overwrite into test select * from mytable;

  • Question: Explain The Tajo Architecture?

    Answer :

    Client: Client submits the SQL statements to the Tajo Master to get the result.

    Master: Master is the main daemon. It is responsible for query planning and is the coordinator for workers.

    Catalog server: Maintains the table and index descriptions. It is embedded in the Master daemon. The catalog server uses Apache Derby as the storage layer and connects via JDBC client.

    Worker: Master node assigns task to worker nodes. TajoWorker processes data. As the number of TajoWorkers increases, the processing capacity also increases linearly.

    Query Master: Tajo master assigns query to the Query Master. The Query Master is responsible for controlling a distributed execution plan. It launches the TaskRunner and schedules tasks to TaskRunner. The main role of the Query Master is to monitor the running tasks and report them to the Master node.

    Node Managers: Manages the resource of the worker node. It decides on allocating requests to the node.

    TaskRunner: Acts as a local query execution engine. It is used to run and monitor query process. The TaskRunner processes one task at a time.

    It has the following three main attributes:

    Logical plan – An execution block which created the task.

    A fragment – an input path, an offset range, and schema.

    Fetches URIs:

    Query Executor: It is used to execute a query.

    Storage service: Connects the underlying data storage to Tajo.

  • Question: What Are Apache Tajo Sql Functions?

    Answer :

    Some of the SQL functions supported by Apache Tajo are categorized into:

    • Math Functions
    • String Functions
    • DateTime Functions
    • JSON Functions
  • Apache Tajo Questions and Answers for Interview

    Preparing for Apache Tajo job interview and whether you’re experienced or fresher & don’t know what kind of questions will be asked in Apache Tajo interview, then go through the above 70+ Top Apache Tajo Interview Questions and Answers to crack your job interview.

    150+ TOP Apache Struts 2 Interview Questions and Answers [UPDATED]

  • Question: What Is The Purpose Of @keyproperty Annotation Annotation?

    Answer :

    This annotation sets the KeyProperty for type conversion. The KeyProperty annotation must be applied at field or method level.

    @KeyProperty( value = “userName” )

    protected List<User> users = null;

  • Question: What Is The Purpose Of @validations Annotation?

    Answer :

    If you want to use several annotations of the same type, these annotation must be nested within the @Validations() annotation.

    public class Employee extends ActionSupport{


       requiredFields =

          {@RequiredFieldValidator(type = ValidatorType.SIMPLE, 

          fieldName = “customfield”, 

          message = “You must enter a value for field.”)},

       requiredStrings =

          {@RequiredStringValidator(type = ValidatorType.SIMPLE, 

          fieldName = “stringisrequired”, 

          message = “You must enter a value for string.”)}


       public String getName() {

           return name;



  • Question: What Is Defeult Result Type?

    Answer :

    Default result type is dispatcher, which is used to dispatch to JSP pages.

  • Question: How Can We Upload Files In Struts2 Application?

    Answer :

    File Upload is one of the common task in a web application. Thats why Struts2 provides built in support for file upload through FileUploadInterceptor. This interceptor is configured in struts-default package and provide options to set the maximum size of a file and file types that can be uploaded to the server.

  • Question: What Is The Default Location Of Result Pages And How Can We Change It?

    Answer :

    By default Struts2 looks for result pages in {WEBAPP-ROOT}/{Namespace}/ directory but sometimes we want to keep result pages in another location, we can provide struts.convention.result.path constant value in Struts2 configuration file to change the result pages location. 

    Another way is to use @ResultPath annotation in action classes to provide the result pages location.

  • Question: What Is The Naming Convention For A Resource Bundle File In Struts2?

    Answer :

    The simplest naming format for a resource file is −


    Here bundlename could be ActionClass, Interface, SuperClass, Model, Package, Global resource properties. Next part language_country represents the country locale for example Spanish (Spain) locale is represented by es_ES and English (United States) locale is represented by en_US etc. Here you can skip country part which is optional.

  • Question: What Are Result Types In Struts?

    Answer :

    The Action class manages the application’s state, and the Result Type manages the view.

  • Question: How Struts 2 Validation Works?

    Answer :

    • When the user presses the submit button, Struts 2 will automatically execute the validate method and if any of the if statements listed inside the method are true, Struts 2 will call its addFieldError method. If any errors have been added then Struts 2 will not proceed to call the execute method. Rather the Struts 2 framework will return input as the result of calling the action.
    • So when validation fails and Struts 2 returns input, the Struts 2 framework will redisplay the view file. Since we used Struts 2 form tags, Struts 2 will automatically add the error messages just above the form filed.
    • These error messages are the ones we specified in the addFieldError method call. The addFieldError method takes two arguments. The first is the form field name to which the error applies and the second is the error message to display above that form field.
  • Question: Which Class Of Struts Is Responsible To Converts Data Types From String And Vice Versa?

    Answer :

    StrutsTypeConverter class tells Struts how to convert Environment to a String and vice versa by overriding two methods convertFromString() and convertToString().

  • Question: What Is Value Stack?

    Answer :

    The value stack is a set of several objects which keeps the following objects in the provided order −

    Temporary Objects − There are various temporary objects which are created during execution of a page. For example the current iteration value for a collection being looped over in a JSP tag.

    The Model Object − If you are using model objects in your struts application, the current model object is placed before the action on the value stack.

    The Action Object − This will be the current action object which is being executed.

    Named Objects − These objects include #application, #session, #request, #attr and #parameters and refer to the corresponding servlet scopes.

  • Question: What Is The Purpose Of Plug-in Tag In Struct-config.xml?

    Answer :

    This section tells Struts where to find your properties files, which contain prompts and error messages.

  • Question: What Is The Purpose Of Constant Tag In Struts.xml?

    Answer :

    The constant tag along with name and value attributes will be used to override any of the following properties defined in default.properties, like we just set struts.devMode property. Setting struts.devMode property allows us to see more debug messages in the log file.

  • Question: How To Override The Default Error Message That Can Come During File Uploading Process?

    Answer :

    You can override the text of these messages in WebContent/WEB-INF/classes/messages.properties resource files.

  • Question: What Is The Purpose Of Struct-config.xml In Struct2?

    Answer :

    The struts-config.xml configuration file is a link between the View and Model components in the Web Client.

  • Question: What Is The Use Of Token Interceptor In Struts2?

    Answer :

    One of the major problems with web applications is the double form submission. If not taken care, double form submission could result in charging double amount to customer or updating database values twice. We can use token interceptor to solve the double form submission problem. This interceptor is defined in struts-default package but it’s not part of any interceptor stack, so we need to include it manually in our action classes.

  • Question: What Are Different Struts2 Tags? How Can We Use Them?

    Answer :

    Struts2 provides a lot of custom tags that we can use in result pages to create views for client request. These tags are broadly divided into three categories- Data tags, Control tags and UI tags. 

    We can use these tags by adding these in JSP pages using taglib directive.

    < %@ taglib uri=”/struts-tags” prefix=”s” % >>

  • Question: What Is The Default Suffix For Struts2 Action Uri And How Can We Change It?

    Answer :

    The default URI suffix for Struts2 action is .action, in Struts1 default suffix was .do. We can change this suffix by defining struts.action.extension constant value in our Struts2 configuration file as:

    < constant name=”struts.action.extension” value=”action,do” > < /constant >

  • Question: What Is The Purpose Of Action-mappings Tag In Struct-config.xml?

    Answer :

    This is where you declare form handlers and they are also known as action mappings.

  • Question: What Is The Purpose Of @typeconversion Annotation Annotation?

    Answer :

    This annotation annotation is used for class and application wide conversion rules. The TypeConversion annotation can be applied at property and method level.

    @TypeConversion(rule = ConversionRule.COLLECTION, 

    converter = “java.util.String”)

    public void setUsers( List users ) {

       this.users = users;


  • Question: What Are The Struts2 Error Message Keys That Can Come During File Uploading Process?

    Answer :

    The fileUplaod interceptor uses several default error message keys −

    struts.messages.error.uploading − A general error that occurs when the file could not be uploaded.

    struts.messages.error.file.too.large − Occurs when the uploaded file is too large as specified by maximumSize.

    struts.messages.error.content.type.not.allowed − Occurs when the uploaded file does not match the expected content types specified.

  • Question: Explain The Life Cycle Of A Request In Struct2 Application?

    Answer :

    Following is the life cycle of a request in Struct2 application −

    • User sends a request to the server for requesting for some resource (i.e pages).
    • The FilterDispatcher looks at the request and then determines the appropriate Action.
    • Configured interceptors functionalities applies such as validation, file upload etc.
    • Selected action is executed to perform the requested operation.
    • Again, configured interceptors are applied to do any post-processing if required.
    • Finally the result is prepared by the view and returns the result to the user.
  • Question: What Is The Purpose Of Dispatcher Result Type?

    Answer :

    The dispatcher result type is the default type, and is used if no other result type is specified. It’s used to forward to a servlet, JSP, HTML page, and so on, on the server. It uses the RequestDispatcher.forward() method.

  • Question: What Is The Purpose Of @conversion Annotation Annotation?

    Answer :

    This is a marker annotation for type conversions at Type level. The Conversion annotation must be applied at Type level.


       public class ConversionAction implements Action {


  • Question: What Is The Purpose Of @element Annotation Annotation?

    Answer :

    This annotation sets the Element for type conversion. The Element annotation must be applied at field or method level.

    @Element( value = com.acme.User )

    private List<User> userList;

  • Question: What Is The Use Of Execandwait Interceptor?

    Answer :

    Struts2 provides execAndWait interceptor for long running action classes. We can use this interceptor to return an intermediate response page to the client and once the processing is finished, final response is returned to the client. This interceptor is defined in the struts-default package and implementation is present in ExecuteAndWaitInterceptor class.

  • Question: Which Interceptor Is Responsible For File Upload Support?

    Answer :

    File uploading in Struts is possible through a pre-defined interceptor called FileUpload interceptor which is available through the org.apache.struts2.interceptor.FileUploadInterceptor class and included as part of the defaultStack.

  • Question: What Is An Interceptor Stack?

    Answer :

    An interceptor stack helps us to group together multiple interceptors in a package for further use. struts-default package creates some of the mostly used interceptor stack – basicStack and defaultStack. We can create our own interceptor stack at the start of the package and then configure our action classes to use it.

  • Question: Which Interceptor Is Responsible For Mapping Request Parameters To Action Class Java Bean Properties?

    Answer :

    com.opensymphony.xwork2.interceptor.ParametersInterceptor interceptor is responsible for mapping request parameters to the Action class java bean properties. This interceptor is configured in struts-default package with name “params”. This interceptor is part of basicStack and defaultStack interceptors stack.

  • Question: What Is Structs 2 Validation Framework?

    Answer :

    At Struts’s core, we have the validation framework that assists the application to run the rules to perform validation before the action method is executed. Action class should extend the ActionSupport class, in order to get the validate method executed.

  • Question: Name Some Of The Features Of Struts2?

    Answer :

    Here are some of the great features that may force you to consider Struts2 −

    POJO forms and POJO actions − Struts2 has done away with the Action Forms that were an integral part of the Struts framework. With Struts2, you can use any POJO to receive the form input. Similarly, you can now see any POJO as an Action class.

    Tag support − Struts2 has improved the form tags and the new tags allow the developers to write less code.

    AJAX support − Struts2 has recognised the take over by Web2.0 technologies, and has integrated AJAX support into the product by creating AJAX tags, that function very similar to the standard Struts2 tags.

    Easy Integration − Integration with other frameworks like Spring, Tiles and SiteMesh is now easier with a variety of integration available with Struts2.

    Template Support − Support for generating views using templates.

    Plugin Support − The core Struts2 behaviour can be enhanced and augmented by the use of plugins. A number of plugins are available for Struts2.

  • Question: What Types Of Validations Are Available In Xml Based Validation In Struts2?

    Answer :

    Following is the list of various types of field level and non-field level validation available in Struts2 −

    • date validator
    • double validator
    • email validator
    • expression validator
    • int validator
    • regex validator
    • required validator
    • requiredstring validator
    • stringlength validator
    • url validator
  • Question: In Which Order Struts Framework Searches For A Message Bundle?

    Answer :

    When you reference a message element by its key, Struts framework searches for a corresponding message bundle in the following order −

    • ActionClass.properties
    • Interface.properties
    • SuperClass.properties
    • model.properties
    • package.properties
    • struts.properties
    • global.properties
  • Question: What Is The Difference In Using Action Interface And Actionsupport Class For Our Action Classes, Which One You Would Prefer?

    Answer :

    We can implement Action interface to create our action classes. This interface has a single method execute() that we need to implement. The only benefit of using this interface is that it contains some constants that we can use for result pages, these constants are SUCCESS, ERROR, NONE, INPUT and LOGIN. 

    ActionSupport class is the default implementation of Action interface and it also implements interfaces related to Validation and i18n support. ActionSupport class implements Action, Validateable, ValidationAware, TextProvider and LocaleProvider interfaces. We can override validate() method of ActionSupport class to include field level validation login in our action classes. 

    Depending on the requirements, we can use any of the approaches to create struts 2 action classes, my favorite is ActionSupport class because it helps in writing validation and i18n logic easily in action classes.

  • Question: What Is Ognl?

    Answer :

    The Object-Graph Navigation Language (OGNL) is a powerful expression language that is used to reference and manipulate data on the ValueStack. OGNL also helps in data transfer and type conversion.

  • Question: How Interceptor Works In Struts 2?

    Answer :

    • Actual action will be executed using the interceptor by invocation.invoke() call. So you can do some pre-processing and some post-processing based on your requirement.
    • The framework itself starts the process by making the first call to the ActionInvocation object’s invoke(). Each time invoke() is called, ActionInvocation consults its state and executes whichever interceptor comes next. When all of the configured interceptors have been invoked, the invoke() method will cause the action itself to be executed.
  • Question: What Is The Purpose Of @emailvalidator Annotation?

    Answer :

    This validation annotation checks that a field is a valid e-mail address if it contains a non-empty String.

    public class Employee extends ActionSupport{

       @EmailValidator(message = “Default message”, 

       key = “i18n.key”, shortCircuit = true)

       public String getEmail() {

           return email;



  • Question: Does Struts2 Action And Interceptors Are Thread Safe?

    Answer :

    • Struts2 Action classes are thread safe because an object is instantiated for every request to handle it. 
    • Struts2 interceptors are singleton classes and a new thread is created to handle the request, so it’s not thread safe and we need to implement them carefully to avoid any issues with shared data.
  • Question: What Is The Purpose Of @results Annotation?

    Answer :

    A @Results annotation is a collection of results. Under the @Results annotation, we can have multiple @Result annotations.


       @Result(name=”success”, value=”/success.jsp”),

       @Result(name=”error”, value=”/error.jsp”)


    public class Employee extends ActionSupport{



  • Question: What Is The Purpose Of @key Annotation Annotation?

    Answer :

    This annotation sets the Key for type conversion. The Key annotation must be applied at field or method level.

    @Key( value = java.lang.Long.class )

    private Map<Long, User> userMap;

  • Question: What Is Valuestack And Ognl?

    Answer :

    ValueStack is the storage area where the application data is stored by Struts2 for processing the client requests. The data is stored in ActionContext objects that use ThreadLocal to have values specific to the particular request thread. 

    Object-Graph Navigation Language (OGNL) is a powerful Expression Language that is used to manipulate data stored on the ValueStack. As you can see in architecture diagram, both interceptors and result pages can access data stored on ValueStack using OGNL.

  • Question: How Can We Integrate Log4j In Struts2 Application?

    Answer :

    Struts2 provides easy integration of log4j API for logging purpose, all we need to have is log4j configuration file in the WEB-INF/classes directory.

  • Question: What Is Struts2?

    Answer :

    Struts2 is popular and mature web application framework based on the MVC design pattern. Struts2 is not just the next version of Struts 1, but it is a complete rewrite of the Struts architecture.

  • Question: What Is The Purpose Of @doublerangefieldvalidator Annotation?

    Answer :

    his validation annotation checks that a double field has a value within a specified range. If neither min nor max is set, nothing will be done.

    public class Employee extends ActionSupport{

       @DoubleRangeFieldValidator(message = “Default message”, 

       key = “i18n.key”, shortCircuit = true, 

       minInclusive = “0.123”, maxInclusive = “99.987”)

       public String getIncome() {

           return income;



  • Question: Provide Some Important Struts2 Constants That You Have Used?

    Answer :

    Some of the Struts2 constants that I have used are: 

    • struts.devMode to run our application in development mode. This mode does reload properties files and provides extra logging and debugging feature. It’s very useful while developing our application but we should turn it off while moving our code to production. 
    • struts.convention.result.path to configure the location of result pages. By default Struts2 look for result pages at {WEBAPP-ROOT}/{Namespace}/ and we can change the location with this constant. 
    • struts.custom.i18n.resources to define global resource bundle for i18n support. 
    • struts.action.extension to configure the URL suffix to for Struts2 application. Default suffix is .action but sometimes we might want to change it to . do or something else. 

    We can configure above constants in struts.xml file like below. 

    < constant name=”struts.devMode” value=”true” > < /constant >

    < constant name=”struts.action.extension” value=”action,do” > < /constant >

    < constant name=”struts.custom.i18n.resources” value=”global” > < /constant >

    < constant name=”struts.convention.result.path” value=”/” > < /constant >

  • Question: What Are Best Practices To Follow While Developing Struts2 Application?

    Answer :

    Some of the best practices while developing Struts2 application are: 

    • Always try to extend struts-default package while creating your package to avoid code redundancy in configuring interceptors. 
    • For common tasks across the application, such as logging request params, try to use interceptors. 
    • Always keep action classes java bean properties in a separate bean for code reuse and implement ModelDriven interface. 
    • If you have custom interceptor that you will use in multiple actions, create interceptor stack for that and then use it. 
    • Try to divide your application in different modules with namespace configuration based on functional areas. 
    • Try to use Struts2 tags in result pages for code clarify, if needed create your own type converters. 
    • Use development mode for faster development, however make sure production code doesn’t run in dev mode. 
    • Use Struts2 i18n support for resource bundles and to support localization. 
    • Struts2 provides a lot of places where you can have resource bundles but try to keep one global resource bundle and one for action class to avoid confusion. 
    • struts-default package configures all the interceptors and creates different interceptor stacks. Try to use only what is needed, for example if you don’t have localization requirement, you can avoid i18n interceptor.
  • Question: Which Components Are Available Using Actioncontext Map?

    Answer :

    The ActionContext map consists of the following −

    application − application scoped variables.

    session − session scoped variables.

    root / value stack − all your action variables are stored here.

    request − request scoped variables.

    parameters − request parameters.

    atributes − the attributes stored in page, request, session and application scope.

  • Question: What Is The Purpose Of Form-beans Tag In Struct-config.xml?

    Answer :

    This is where you map your ActionForm subclass to a name. You use this name as an alias for your ActionForm throughout the rest of the struts-config.xml file, and even on your JSP pages.

  • Question: What Is The Purpose Of @stringlengthfieldvalidator Annotation?

    Answer :

    This validator checks that a String field is of the right length. It assumes that the field is a String. If neither minLength nor maxLength is set, nothing will be done.

    public class Employee extends ActionSupport{

       @StringLengthFieldValidator(message = “Default message”, 

       key = “i18n.key”, shortCircuit = true, 

       trim = true, minLength = “5”,  maxLength = “12”)

       public String getName() {

           return name;



  • Question: What Is The Purpose Of @result Annotation?

    Answer :

    The @result annotations have the name that correspond to the outcome of the execute method. They also contain a location as to which view should be served corresponding to return value from execute().

    @Result(name=”success”, value=”/success.jsp”)

    public class Employee extends ActionSupport{



  • Question: What Is The Purpose Of @createifnull Annotation Annotation?

    Answer :

    This annotation sets the CreateIfNull for type conversion. The CreateIfNull annotation must be applied at field or method level.

    @CreateIfNull( value = true )

    private List<User> users;

  • Question: What Are The Struts2 Configuration Properties That Control File Uploading Process?

    Answer :

    Following are the Struts2 configuration properties that control file uploading process −

    struts.multipart.maxSize − The maximum size (in bytes) of a file to be accepted as a file upload. Default is 250M.

    struts.multipart.parser − The library used to upload the multipart form. By default is jakarta.

    struts.multipart.saveDir − The location to store the temporary file. By default is javax.servlet.context.tempdir.

  • Question: What Is Life Cycle Of An Interceptor?

    Answer :

    Interceptor interface defines three methods – init(), destroy() and intercept(). init and destroy are the life cycle methods of an interceptor. Interceptors are Singleton classes and Struts2 initialize a new thread to handle each request. init() method is called when interceptor instance is created and we can initialize any resources in this method. destroy() method is called when application is shutting down and we can release any resources in this method. 

  • Question: What Is Xml Based Validation In Struts2?

    Answer :

    The second method of doing validation is by placing an xml file next to the action class. Struts2 XML based validation provides more options of validation like email validation, integer range validation, form validation field, expression validation, regex validation, required validation, requiredstring validation, stringlength validation and etc.

  • Question: Which Interceptor Is Responsible For I18n Support?

    Answer :

    com.opensymphony.xwork2.interceptor.I18nInterceptor interceptor is responsible for i18n support in Struts2 applications. This interceptor is configured in struts-default package with name “i18n” and it’s part of i18nStack and defaultStack.

  • Question: What Is The Purpose Of @customvalidator Annotation?

    Answer :

    This annotation can be used for custom validators. Use the ValidationParameter annotation to supply additional params.

    @CustomValidator(type =”customValidatorName”, fieldName = “myField”)

  • Question: What Is The Purpose Of Struts.properties In Struct2?

    Answer :

    This configuration file provides a mechanism to change the default behavior of the framework. Actually all of the properties contained within the struts.properties configuration file can also be configured in the web.xml using the init-param, as well using the constant tag in the struts.xml configuration file. But if you like to keep the things separate and more struts specific then you can create this file under the folder WEB-INF/classes. The values configured in this file will override the default values configured in default.properties which is contained in the struts2-core-x.y.z.jar distribution.

  • Question: What Is The Purpose Of Global-forwards Tag In Struct-config.xml?

    Answer :

    This section maps a page on your webapp to a name. You can use this name to refer to the actual page. This avoids hardcoding URLs on your web pages.

  • Question: What Are The Core Components Of A Struct2 Based Application?

    Answer :

    The Model-View-Controller pattern in Struts2 is realized with following five core components −

    • Actions
    • Interceptors
    • Value Stack / OGNL
    • Results / Result types
    • View technologies
  • Question: How Struts2 Supports Internationalization?

    Answer :

    Struts2 provides localization ie. internationalization (i18n) support through resource bundles, interceptors and tag libraries in the following places −

    • The UI Tags.
    • Messages and Errors.
    • Within action classes.
  • Question: What Is Internationalization?

    Answer :

    Internationalization (i18n) is the process of planning and implementing products and services so that they can easily be adapted to specific local languages and cultures, a process called localization. The internationalization process is sometimes called translation or localization enablement.

  • Question: What Is The Purpose Of @expressionvalidator Annotation?

    Answer :

    This non-field level validator validates a supplied regular expression.

    @ExpressionValidator(message = “Default message”, key = “i18n.key”, shortCircuit = true, expression = “an OGNL expression” )

  • Question: Name Some Useful Annotations Introduced In Struts2?

    Answer :

    Some of the important annotations introduced in Struts2 are: 

    • @Action to create action class
    • @Actions to configure single class for multiple actions
    • @Namespace and @Namespaces for creating different modules
    • @Result for result pages
    • @ResultPath for configuring result pages location
  • Question: What Is The Use Of Namespace In Action Mapping In Struts2?

    Answer :

    Struts2 namespace configuration allows us to create modules easily. We can use namespace to separate our action classes based on their functionality, for example admin, user, customer etc.

  • Question: What Is Struts-default Package And What Are It’s Benefits?

    Answer :

    struts-default is an abstract package that defines all the Struts2 interceptors and commonly used interceptor stack. It is advisable to extend this package while configuring our application package to avoid configuring interceptors again. This is provided to help developers by eliminating the trivial task of configuring interceptor and result pages in our application.

  • Question: What Is The Purpose Of @after Annotation?

    Answer :

    The @After annotation marks a action method that needs to be called after the main action method and the result was executed. Return value is ignored.

    public class Employee extends ActionSupport{


       public void isValid() throws ValidationException {

          // validate model object, throw exception if failed


       public String execute() {

          // perform secure action

          return SUCCESS;



  • Question: How Can You Create Your Custom Interceptor In Struts 2?

    Answer :

    Creating a custom interceptor is easy; the interface that needs to be extended is the Interceptor interface.

  • Question: What Is The Purpose Of Redirect Result Type?

    Answer :

    The redirect result type calls the standard response.sendRedirect() method, causing the browser to create a new request to the given location. We can provide the location either in the body of the <result…> element or as a <param name=”location”> element.

  • Question: What Is The Purpose Of Struts.xml In Struct2?

    Answer :

    The struts.xml file contains the configuration information that you will be modifying as actions are developed. This file can be used to override default settings for an application, for example struts.devMode = false and other settings which are defined in property file. This file can be created under the folder WEB-INF/classes.

  • Question: How Can We Get Servlet Api Request, Response, Httpsession Etc Objects In Action Classes?

    Answer :

    Struts2 action classes doesn’t provide direct access to Servlet API components such as Request, Response and Session. However sometimes we need these access in action classes such as checking HTTP method or setting cookies in response. 

    That’s why Struts2 API provides a bunch of *Aware interfaces that we can implement to access these objects. Struts2 API uses dependency injection to inject Servlet API components in action classes. Some of the important Aware interfaces are SessionAware, ApplicationAware, ServletRequestAware and ServletResponseAware.

  • Question: Which Class Is The Front Controller In Struts2?

    Answer :

    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter is the Front Controller class in Struts2 and every request processing starts from this class. Earlier versions of Struts2 uses org.apache.struts2.dispatcher.FilterDispatcher as Front Controller class

  • Question: How To Handle Exceptions In Structs?

    Answer :

    Struts makes the exception handling easy by the use of the “exception” interceptor. The “exception” interceptor is included as part of the default stack, so you don’t have to do anything extra to configure it. It is available out-of-the-box ready for you to use.

  • Question: What Is The Purpose Of @before Annotation?

    Answer :

    The @Before annotation marks a action method that needs to be called before the main action method and the result was executed. Return value is ignored.

    public class Employee extends ActionSupport{


       public void isAuthorized() throws AuthenticationException {

          // authorize request, throw exception if failed


       public String execute() {

          // perform secure action

          return SUCCESS;



  • Question: What Are Different Ways To Create Action Classes In Struts2?

    Answer :

    Struts2 provide different ways to create action classes. 

    • By implementing Action interface
    • Using Struts2 @Action annotation
    • By extending ActionSupport class
    • Any normal java class with execute() method returning String can be configured as Action class.
  • Question: What Inbuilt Themes Are Provided By Struts2?

    Answer :

    Struts 2 comes with three built-in themes −

    simple theme − A minimal theme with no “bells and whistles”. For example, the textfield tag renders the HTML <input/> tag without a label, validation, error reporting, or any other formatting or functionality.

    xhtml theme − This is the default theme used by Struts 2 and provides all the basics that the simple theme provides and adds several features like standard two-column table layout for the HTML, Labels for each of the HTML, Validation and error reporting etc.

    css_xhtml theme − This theme provides all the basics that the simple theme provides and adds several features like standard two-column CSS-based layout, using <div> for the HTML Struts Tags, Labels for each of the HTML Struts Tags, placed according to the CSS stylesheet.

  • Question: What Are The Benefits Of Interceptors In Struts2?

    Answer :

    Some of the benefits of interceptors are: 

    • Interceptor plays a crucial role in achieving high level of separation of concerns.
    • Struts2 interceptors are configurable, we can configure it for any action we want.
    • We can create our own custom interceptors to perform some common tasks such as request params logging, authentication etc. This helps us in taking care of common tasks at a single location, achieving low maintenance cost.
    • We can create interceptors stack to use with different actions.
  • Question: What Is The Purpose Of @conversionerrorfieldvalidator Annotation?

    Answer :

    This validation annotation checks if there are any conversion errors for a field and applies them if they exist.

    public class Employee extends ActionSupport{

       @ConversionErrorFieldValidator(message = “Default message”, 

                            key = “i18n.key”, shortCircuit = true)

       public String getName() {

           return name;



  • Question: What Is The Purpose Of @urlvalidator Annotation?

    Answer :

    This validator checks that a field is a valid URL.

    public class Employee extends ActionSupport{

       @UrlValidator(message = “Default message”, 

       key = “i18n.key”, shortCircuit = true)

       public String getURL() {

           return url;



  • Question: What Are Interceptors In Struts 2?

    Answer :

    Interceptors are conceptually the same as servlet filters or the JDKs Proxy class. Interceptors allow for crosscutting functionality to be implemented separately from the action as well as the framework.

    You can achieve the following using interceptors :

    • Providing preprocessing logic before the action is called.
    • Providing postprocessing logic after the action is called.
    • Catching exceptions so that alternate processing can be performed.
  • Question: What Is The Purpose Of Action Tag In Struts.xml?

    Answer :

    We define action tags corresponds to every URL we want to access and we define a class with execute() method which will be accessed whenever we will access corresponding URL.

    Results determine what gets returned to the browser after an action is executed. The string returned from the action should be the name of a result. Results are configured per-action as above, or as a “global” result, available to every action in a package. Results have optional name and type attributes. The default name value is “success”.

  • Question: What Is The Purpose Of @action Annotation?

    Answer :

    This is used to decorate the execute() method. The Action method also takes in a value which is the URL on which the action is invoked.

    public class Employee extends ActionSupport{

       private String name;

       private int age;


       public String execute() 


           return SUCCESS;



  • Question: What Are Struts2 Core Components?

    Answer :

    Struts2 core components are: A.Action Classes B.Interceptors C.Result Pages, JSP of FreeMarker templates D.ValueStack, OGNL and Tag Libraries .

  • Question: What Is The Purpose Of @intrangefieldvalidator Annotation?

    Answer :

    This validation annotation checks that a numeric field has a value within a specified range. If neither min nor max is set, nothing will be done.

    public class Employee extends ActionSupport{

       @IntRangeFieldValidator(message = “Default message”, 

       key = “i18n.key”, shortCircuit = true, 

       min = “0”, max = “42”)

       public String getAge() {

           return age;



  • Question: What Is The Purpose Of @requiredstringvalidator Annotation?

    Answer :

    This validation annotation checks that a String field is not empty (i.e. non-null with a length > 0).

    public class Employee extends ActionSupport{

       @RequiredStringValidator(message = “Default message”, 

       key = “i18n.key”, shortCircuit = true, trim = true)

       public String getName() {

           return name;



  • Question: What Is The Purpose Of @beforeresult Annotation?

    Answer :

    The @BeforeResult annotation marks a action method that needs to be executed before the result. Return value is ignored.

    public class Employee extends ActionSupport{


       public void isValid() throws ValidationException {

        // validate model object, throw exception if failed


       public String execute() {

          // perform action

          return SUCCESS;



  • Question: What Is Custom Type Converter In Struts2?

    Answer :

    Struts2 support OGNL expression language and it performs two important tasks in Struts 2 – data transfer and type conversion. 

    OGNL is flexible and we can easily extend it to create our own custom converter class. Creating and configuring custom type converter class is very easy, first step is to fix the input format for the custom class. Second step is to implement the converter class. Type converter classes should implement com.opensymphony.xwork2.conversion.TypeConverter interface. Since in web application, we always get the request in form of String and send response in the form of String, Struts 2 API provides a default implementation of TypeConverter interface, StrutsTypeConverter. StrutsTypeConverter contains two abstract methods – convertFromString to convert String to Object and convertToString to convert Object to String.

  • Question: What Should Be The Name Of Xml File Used For Validation In Struts?

    Answer :

    The xml file needs to be named ‘[action-class]’-validation.xml.

  • Apache Struts 2 Questions and Answers for Interview

    Preparing for Apache Struts 2 job interview and whether you’re experienced or fresher & don’t know what kind of questions will be asked in Apache Struts 2 interview, then go through the above 150+ Top Apache Struts 2 Interview Questions and Answers to crack your job interview.

    80+ TOP Apache Storm Interview Questions and Answers [UPDATED]

  • Question: Does Apache Act As A Proxy Server?

    Answer :

    Yes, It acts as proxy also by using the mod_proxy module. This module implements a proxy, gateway or cache for Apache. It implements proxying capability for AJP13 (Apache JServ Protocol version 1.3), FTP, CONNECT (for SSL),HTTP/0.9, HTTP/1.0, and (since Apache 1.3.23) HTTP/1.1. The module can be configured to connect to other proxy modules for these and other protocols.

  • Question: What Is The Use Of Zookeeper In Storm?

    Answer :

    Storm uses Zookeeper for coordinating the cluster. Zookeeper is not used for message passing, so the load that Storm places on Zookeeper is quite low. Single node Zookeeper clusters should be sufficient for most cases, but if you want failover or are deploying large Storm clusters you may want larger Zookeeper clusters. Instructions for deploying Zookeeper are here.

    A few notes about Zookeeper deployment :

    It’s critical that you run Zookeeper under supervision, since Zookeeper is fail-fast and will exit the process if it encounters any error case. See here for more details.

    It’s critical that you set up a cron to compact Zookeeper’s data and transaction logs. The Zookeeper daemon does not do this on its own, and if you don’t set up a cron, Zookeeper will quickly run out of disk space.

  • Question: What Is Zeromq?

    Answer :

    ZeroMQ is “a library which extends the standard socket interfaces with features traditionally provided by specialized messaging middleware products”. Storm relies on ZeroMQ primarily for task-to-task communication in running Storm topologies.

  • Question: Does Apache Include Any Sort Of Database Integration?

    Answer :

    Apache is a Web (HTTP) server, not an application server. The base package does not include any such functionality. PHP project and the mod_perl project allow you to work with databases from within the Apache environment.

  • Question: What Are The Common Configurations In Apache Storm?

    Answer :

    There are a variety of configurations you can set per topology. A list of all the configurations you can set can be found here. The ones prefixed with “TOPOLOGY” can be overridden on a topology-specific basis (the other ones are cluster configurations and cannot be overridden).

    Here are some common ones that are set for a topology:

    1   Config.TOPOLOGY_WORKERS : This sets the number of worker processes to use to execute the topology. For example, if you set this to 25, there will be 25 Java processes across the cluster executing all the tasks. If you had a combined 150 parallelism across all components in the topology, each worker process will have 6 tasks running within it as threads.

    2  Config.TOPOLOGY_ACKER_EXECUTORS : This sets the number of executors that will track tuple trees and detect when a spout tuple has been fully processed By not setting this variable or setting it as null, Storm will set the number of acker executors to be equal to the number of workers configured for this topology. If this variable is set to 0, then Storm will immediately ack tuples as soon as they come off the spout, effectively disabling reliability.

    3  Config.TOPOLOGY_MAX_SPOUT_PENDING : This sets the maximum number of spout tuples that can be pending on a single spout task at once (pending means the tuple has not been acked or failed yet). It is highly recommended you set this config to prevent queue explosion.

    4  Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS : This is the maximum amount of time a spout tuple has to be fully completed before it is considered failed. This value defaults to 30 seconds, which is sufficient for most topologies.

    5  Config.TOPOLOGY_SERIALIZATIONS : You can register more serializers to Storm using this config so that you can use custom types within tuples.

  • Question: How To Check For The Httpd.conf Consistency And Any Errors In It?

    Answer :

    We can check syntax for httpd configuration file by using following command.

    httpd –S

    This command will dump out a description of how Apache parsed the configuration file. Careful examination of the IP addresses and server names may help uncover configuration mistakes.

  • Question: While Installing, Why Does Apache Have Three Config Files – Srm.conf, Access.conf And Httpd.conf?

    Answer :

    The first two are remnants from the NCSA times, and generally you should be fine if you delete the first two, and stick with httpd.conf.

    srm.conf :- This is the default file for the ResourceConfig directive in httpd.conf. It is processed after httpd.conf but before access.conf.

    access.conf :- This is the default file for the AccessConfig directive in httpd.conf.It is processed after httpd.conf and srm.conf.

    httpd.conf :-The httpd.conf file is well-commented and mostly self-explanatory.

  • Question: Tell Me Is Running Apache As A Root Is A Security Risk?

    Answer :

    No. Root process opens port 80, but never listens to it, so no user will actually enter the site with root rights. If you kill the root process, you will see the other roots disappear as well.

  • Question: Which Components Are Used For Stream Flow Of Data?

    Answer :

    For streaming of data flow, three components are used:

    Bolt :- Bolts represent the processing logic unit in Storm. One can utilize bolts to do any kind of processing such as filtering, aggregating, joining, interacting with data stores, talking to external systems etc. Bolts can also emit tuples (data messages) for the subsequent bolts to process. Additionally, bolts are responsible to acknowledge the processing of tuples after they are done processing.

    Spout :- Spouts represent the source of data in Storm. You can write spouts to read data from data sources such as database, distributed file systems, messaging frameworks etc. Spouts can broadly be classified into following –

    Reliable – These spouts have the capability to replay the tuples (a unit of data in data stream). This helps applications achieve ‘at least once message processing’ semantic as in case of failures, tuples can be replayed and processed again. Spouts for fetching the data from messaging frameworks are generally reliable as these frameworks provide the mechanism to replay the messages.

    Unreliable – These spouts don’t have the capability to replay the tuples. Once a tuple is emitted, it cannot be replayed irrespective of whether it was processed successfully or not. This type of spouts follow ‘at most once message processing’ semantic.

    Tuple :- The tuple is the main data structure in Storm. A tuple is a named list of values, where each value can be any type. Tuples are dynamically typed — the types of the fields do not need to be declared. Tuples have helper methods like getInteger and getString to get field values without having to cast the result. Storm needs to know how to serialize all the values in a tuple. By default, Storm knows how to serialize the primitive types, strings, and byte arrays. If you want to use another type, you’ll need to implement and register a serializer for that type.

  • Question: Mention How Storm Application Can Be Beneficial In Financial Services?

    Answer :

    In financial services, Storm can be helpful in preventing

    Securities fraud :

    1. Perform real-time anomaly detection on known patterns of activities and use learned patterns from prior modeling and simulations.
    2. Correlate transaction data with other streams (chat, email, etc.) in a cost-effective parallel processing environment.
    3. Reduce query time from hours to minutes on large volumes of data.
    4. Build a single platform for operational applications and analytics that reduces total cost of ownership (TCO)

    Order routing : Order routing is the process by which an order goes from the end user to an exchange. An order may go directly to the exchange from the customer, or it may go first to a broker who then routes the order to the exchange.

    Pricing : Pricing is the process whereby a business sets the price at which it will sell its products and services, and may be part of the business’s marketing plan.

    Compliance Violations : compliance means conforming to a rule, such as a specification, policy, standard or law. Regulatory compliance describes the goal that organizations aspire to achieve in their efforts to ensure that they are aware of and take steps to comply with relevant laws and regulations. And any disturbance in regarding compliance is violations in compliance.

  • Question: How Many Distinct Layers Are Of Storm’s Codebase?

    Answer :

    There are three distinct layers to Storm’s codebase:

    First : Storm was designed from the very beginning to be compatible with multiple languages. Nimbus is a Thrift service and topologies are defined as Thrift structures. The usage of Thrift allows Storm to be used from any language.

    Second : all of Storm’s interfaces are specified as Java interfaces. So even though there’s a lot of Clojure in Storm’s implementation, all usage must go through the Java API. This means that every feature of Storm is always available via Java.

    Third : Storm’s implementation is largely in Clojure. Line-wise, Storm is about half Java code, half Clojure code. But Clojure is much more expressive, so in reality the great majority of the implementation logic is in Clojure.

  • Question: How Can We Kill A Topology?

    Answer :

    To kill a topology, simply run:

    storm kill {stormname}

    Give the same name to storm kill as you used when submitting the topology.

    Storm won’t kill the topology immediately. Instead, it deactivates all the spouts so that they don’t emit any more tuples, and then Storm waits Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS seconds before destroying all the workers. This gives the topology enough time to complete any tuples it was processing when it got killed.

  • Question: What Does It Mean For A Message To Be?

    Answer :

    A tuple coming off a spout can trigger thousands of tuples to be created based on it. Consider.

    for example:

    the streaming word count topology:TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout(“sentences”, new KestrelSpout(“kestrel.backtype.com”,
    new StringScheme()));
    builder.setBolt(“split”, new SplitSentence(), 10)
    builder.setBolt(“count”, new WordCount(), 20)
    .fieldsGrouping(“split”, new Fields(“word”));

    This topology reads sentences off a Kestrel queue, splits the sentences into its constituent words, and then emits for each word the number of times it has seen that word before. A tuple coming off the spout triggers many tuples being created based on it: a tuple for each word in the sentence and a tuple for the updated count for each word.

    Storm considers a tuple coming off a spout “fully processed” when the tuple tree has been exhausted and every message in the tree has been processed. A tuple is considered failed when its tree of messages fails to be fully processed within a specified timeout. This timeout can be configured on a topology-specific basis using the Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS configuration and defaults to 30 seconds.

  • Question: Mention The Difference Between Apache Kafka And Apache Storm?

    Answer :

    Apache Kafka : It is a distributed and robust messaging system that can handle huge amount of data and allows passage of messages from one end-point to another. Kafka is designed to allow a single cluster to serve as the central data backbone for a large organization. It can be elastically and transparently expanded without downtime. Data streams are partitioned and spread over a cluster of machines to allow data streams larger than the capability of any single machine and to allow clusters of coordinated consumers.


    Apache Storm : It is a real time message processing system, and you can edit or manipulate data in real-time. Storm pulls the data from Kafka and applies some required manipulation. It makes it easy to reliably process unbounded streams of data, doing real-time processing what Hadoop did for batch processing. Storm is simple, can be used with any programming language, and is a lot of fun to use.

  • Question: Why Does Not Apache Include Ssl?

    Answer :

    SSL (Secure Socket Layer) data transport requires encryption, and many governments have restrictions upon the import, export, and use of encryption technology. If Apache included SSL in the base package, its distribution would involve all sorts of legal and bureaucratic issues, and it would no longer be freely available. Also, some of the technology required to talk to current clients using SSL is patented by RSA Data Security, who restricts its use without a license.

  • Question: Can We Use Active Server Pages(asp) With Apache?

    Answer :

    Apache Web Server package does not include ASP support. However, a number of projects provide ASP or ASP-like functionality for Apache.

    Some of these are:

    Apache:ASP :- Apache ASP provides Active Server Pages port to the Apache Web Server with Perl scripting only, and enables developing of dynamic web applications with session management and embedded Perl code. There are also many powerful extensions, including XML taglibs, XSLT rendering, and new events not originally part of the ASP AP.

    mod_mono :- It is an Apache 2.0/2.2/2.4.3 module that provides ASP.NET support for the web’s favorite server, Apache. It is hosted inside Apache. Depending on your configuration, the Apache box could be one or a dozen of separate processes, all of these processes will send their ASP.NET requests to the mod-mono-server process. The mod-mono-server process in turn can host multiple independent applications. It does this by using Application Domains to isolate the applications from each other, while using a single Mono virtual machine.

  • Question: Explain How You Can Streamline Log Files Using Apache Storm?

    Answer :

    To read from the log files, you can configure your spout and emit per line as it read the log. The output then can be assign to a bolt for analyzing.

  • Question: What Is Multiviews?

    Answer :

    MultiViews search is enabled by the MultiViews Options. It is the general name given to the Apache server’s ability to provide language-specific document variants in response to a request. This is documented quite thoroughly in the content negotiation description page. In addition, Apache Week carried an article on this subject entitled It then chooses the best match to the client’s requirements, and returns that document.

  • Question: In Which Folder Are Java Application Stored In Apache?

    Answer :

    Java applications are not stored in Apache, it can be only connected to a other Java webapp hosting webserver using the mod_jk connector. mod_jk is a replacement to the elderly mod_jserv. It is a completely new Tomcat-Apache plug-in that handles the communication between Tomcat and Apache.

    Several reasons:

    • mod_jserv was too complex : Because it was ported from Apache/JServ, it brought with it lots of JServ specific bits that aren’t needed by Apache.
    • mod_jserv supported only Apache : Tomcat supports many web servers through a compatibility layer named the jk library. Supporting two different modes of work became problematic in terms of support, documentation and bug fixes. mod_jk should fix that.
    • The layered approach : provided by the jk library makes it easier to support both Apache1.3.x and Apache2.xx.
    • Better support for SSL : mod_jserv couldn’t reliably identify whether a request was made via HTTP or HTTPS. mod_jk can, using the newer Ajpv13 protocol.
  • Question: Is It Necessary To Kill The Topology While Updating The Running Topology?

    Answer :

    Yes, to update a running topology, the only option currently is to kill the current topology and resubmit a new one. A planned feature is to implement a Storm swap command that swaps a running topology with a new one, ensuring minimal downtime and no chance of both topologies processing tuples at the same time.

  • Question: Does Apache Include A Search Engine?

    Answer :

    Yes, Apache contains a Search engine. You can search a report name in Apache by using the “Search title”.

  • Question: What Is Mod_vhost_alias?

    Answer :

    This module creates dynamically configured virtual hosts, by allowing the IP address and/or the Host: header of the HTTP request to be used as part of the path name to determine what files to serve. This allows for easy use of a huge number of virtual hosts with similar configurations.

  • Question: Explain When To Use Field Grouping In Storm? Is There Any Time-out Or Limit To Known Field Values?

    Answer :

    Field grouping in storm uses a mod hash function to decide which task to send a tuple, ensuring which task will be processed in the correct order. For that, you don’t require any cache. So, there is no time-out or limit to known field values.

    The stream is partitioned by the fields specified in the grouping. For example, if the stream is grouped by the “user-id” field, tuples with the same “user-id” will always go to the same task, but tuples with different “user-id”‘s may go to different tasks.

  • Question: Explain What Is Toplogy_message_timeout_secs In Apache Storm?

    Answer :

    It is the maximum amount of time allotted to the topology to fully process a message released by a spout. If the message in not acknowledged in given time frame, Apache Storm will fail the message on the spout.

  • Question: How Storm Ui Can Be Used In Topology?

    Answer :

    Storm UI is used in monitoring the topology. The Storm UI provides information about errors happening in tasks and fine-grained stats on the throughput and latency performance of each component of each running topology.

  • Question: What Is Servertype Directive In Apache Server?

    Answer :

    It defines whether Apache should spawn itself as a child process (standalone) or keep everything in a single process (inetd). Keeping it inetd conserves resources.

    The ServerType directive is included in Apache 1.3 for background compatibility with older UNIX-based version of Apache. By default, Apache is set to standalone server which means Apache will run as a separate application on the server. The ServerType directive isn’t available in Apache 2.0.

  • Question: What Is Combineraggregator?

    Answer :

    A CombinerAggregator is used to combine a set of tuples into a single field. It has the following signature:

    public interface CombinerAggregator {
    T init (TridentTuple tuple);
    T combine(T val1, T val2);
    T zero();

    Storm calls the init() method with each tuple, and then repeatedly calls the combine()method until the partition is processed. The values passed into the combine() method are partial aggregations, the result of combining the values returned by calls to init().

  • Question: When Do You Call The Cleanup Method?

    Answer :

    The cleanup method is called when a Bolt is being shutdown and should cleanup any resources that were opened. There’s no guarantee that this method will be called on the cluster: For instance, if the machine the task is running on blows up, there’s no way to invoke the method.

    The cleanup method is intended when you run topologies in local mode (where a Storm cluster is simulated in process), and you want to be able to run and kill many topologies without suffering any resource leaks.

  • Question: What Are The Key Benefits Of Using Storm For Real Time Processing?

    Answer :

    Easy to operate : Operating storm is quiet easy.

    Real fast : It can process 100 messages per second per node.

    Fault Tolerant : It detects the fault automatically and re-starts the functional attributes.

    Reliable : It guarantees that each unit of data will be executed at least once or exactly once.

    Scalable : It runs across a cluster of machine

  • Apache Storm Questions and Answers for Interview

    Preparing for Apache Storm job interview and whether you’re experienced or fresher & don’t know what kind of questions will be asked in Apache Storm interview, then go through the above 80+ Top Apache Storm Interview Questions and Answers to crack your job interview.

    100+ TOP Apache Spark Interview Questions and Answers [UPDATED]

  • Question: What Is The Difference Between Persist() And Cache()?

    Answer :

    persist () allows the user to specify the storage level where as cache () uses the default storage level.

  • Question: When Running Spark Applications, Is It Necessary To Install Spark On All The Nodes Of Yarn Cluster?

    Answer :

    Spark need not be installed when running a job under YARN or Mesos because Spark can execute on top of YARN or Mesos clusters without affecting any change to the cluster.

  • Question: What Are The Languages Supported By Apache Spark For Developing Big Data Applications?

    Answer :

    Scala, Java, Python, R and Clojure

  • Question: What Is The Advantage Of A Parquet File?

    Answer :

    Parquet file is a columnar format file that helps:

    1. Limit I/O operations
    2. Consumes less space
    3. Fetches only required columns.
  • Question: What Do You Understand By Schemardd?

    Answer :

    An RDD that consists of row objects (wrappers around basic string or integer arrays) with schema information about the type of data in each column.

  • Question: Hadoop Uses Replication To Achieve Fault Tolerance. How Is This Achieved In Apache Spark?

    Answer :

    Data storage model in Apache Spark is based on RDDs. RDDs help achieve fault tolerance through lineage. RDD always has the information on how to build from other datasets. If any partition of a RDD is lost due to failure, lineage helps build only that particular lost partition.

  • Question: Does Apache Spark Provide Check Pointing?

    Answer :

    Lineage graphs are always useful to recover RDDs from a failure but this is generally time consuming if the RDDs have long lineage chains. Spark has an API for check pointing i.e. a REPLICATE flag to persist. However, the decision on which data to checkpoint – is decided by the user. Checkpoints are useful when the lineage graphs are long and have wide dependencies.

  • Question: What Do You Understand By Pair Rdd?

    Answer :

    Special operations can be performed on RDDs in Spark using key/value pairs and such RDDs are referred to as Pair RDDs. Pair RDDs allow users to access each key in parallel. They have a reduceByKey () method that collects data based on each key and a join () method that combines different RDDs together, based on the elements having the same key.

  • Question: What Are The Various Data Sources Available In Sparksql?

    Answer :

    1. Parquet file
    2. JSON Datasets
    3. Hive tables
  • Question: What Does The Spark Engine Do?

    Answer :

    Spark engine schedules, distributes and monitors the data application across the spark cluster.

  • Question: What Are The Benefits Of Using Spark With Apache Mesos?

    Answer :

    It renders scalable partitioning among various Spark instances and dynamic partitioning between Spark and other big data frameworks.

  • Question: Which Spark Library Allows Reliable File Sharing At Memory Speed Across Different Cluster Frameworks?

    Answer :


  • Question: What Is Spark Core?

    Answer :

    It has all the basic functionalities of Spark, like – memory management, fault recovery, interacting with storage systems, scheduling tasks, etc.

  • Question: What Is Rdd?

    Answer :

    RDDs (Resilient Distributed Datasets) are basic abstraction in Apache Spark that represent the data coming into the system in object format. RDDs are used for in-memory computations on large clusters, in a fault tolerant manner. RDDs are read-only portioned, collection of records, that are –

    Immutable – RDDs cannot be altered.

    Resilient – If a node holding the partition fails the other node takes the data.

  • Question: Can You Use Spark To Access And Analyse Data Stored In Cassandra Databases?

    Answer :

    Yes, it is possible if you use Spark Cassandra Connector.

  • Question: Explain About The Popular Use Cases Of Apache Spark?

    Answer :

    Apache Spark is mainly used for:

    • Iterative machine learning.
    • Interactive data analytics and processing.
    • Stream processing
    • Sensor data processing
  • Question: Is It Possible To Run Spark And Mesos Along With Hadoop?

    Answer :

    Yes, it is possible to run Spark and Mesos with Hadoop by launching each of these as a separate service on the machines. Mesos acts as a unified scheduler that assigns tasks to either Spark or Hadoop.

  • Question: Explain About The Different Cluster Managers In Apache Spark?

    Answer :

    The 3 different clusters managers supported in Apache Spark are:

    1. YARN
    2. Apache Mesos –Has rich resource scheduling capabilities and is well suited to run Spark along with other applications. It is advantageous when several users run interactive shells because it scales down the CPU allocation between commands.
    3. Standalone deployments – Well suited for new deployments which only run and are easy to set up.
  • Question: What Are The Key Features Of Apache Spark That You Like?

    Answer :

    • Spark provides advanced analytic options like graph algorithms, machine learning, streaming data, etc
    • It has built-in APIs in multiple languages like Java, Scala, Python and R
    • It has good performance gains, as it helps run an application in the Hadoop cluster ten times faster on disk and 100 times faster in memory.
  • Question: What Do You Understand By Executor Memory In A Spark Application?

    Answer :

    Every spark application has same fixed heap size and fixed number of cores for a spark executor. The heap size is what referred to as the Spark executor memory which is controlled with the spark.executor.memory property of the –executor-memory flag.

    Every spark application will have one executor on each worker node. The executor memory is basically a measure on how much memory of the worker node will the application utilize.

  • Question: What Is A Dstream?

    Answer :

    Discretized Stream is a sequence of Resilient Distributed Databases that represent a stream of data. DStreams can be created from various sources like Apache Kafka, HDFS, and Apache Flume.

    DStreams have two operations: –

    1. Transformations that produce a new DStream.
    2. Output operations that write data to an external system.
  • Question: Is It Necessary To Install Spark On All The Nodes Of A Yarn Cluster While Running Apache Spark On Yarn ?

    Answer :

    No , it is not necessary because Apache Spark runs on top of YARN.

  • Question: Is It Possible To Run Apache Spark On Apache Mesos?

    Answer :

    Yes, Apache Spark can be run on the hardware clusters managed by Mesos.

  • Question: List Some Use Cases Where Spark Outperforms Hadoop In Processing.?

    Answer :

    1. Sensor Data Processing –Apache Spark’s ‘In-memory computing’ works best here, as data is retrieved and combined from different sources.
    2. Spark is preferred over Hadoop for real time querying of data
    3. Stream Processing – For processing logs and detecting frauds in live streams for alerts, Apache Spark is the best solution.
  • Question: What Are The Various Levels Of Persistence In Apache Spark?

    Answer :

    Apache Spark automatically persists the intermediary data from various shuffle operations, however it is often suggested that users call persist () method on the RDD in case they plan to reuse it. Spark has various persistence levels to store the RDDs on disk or in memory or as a combination of both with different replication levels.

    The various storage/persistence levels in Spark are:


  • Question: What Makes Apache Spark Good At Low-latency Workloads Like Graph Processing And Machine Learning?

    Answer :

    Apache Spark stores data in-memory for faster model building and training. Machine learning algorithms require multiple iterations to generate a resulting optimal model and similarly graph algorithms traverse all the nodes and edges.

    These low latency workloads that need multiple iterations can lead to increased performance. Less disk access and  controlled network traffic make a huge difference when there is lots of data to be processed.

  • Question: How Spark Uses Akka?

    Answer :

    Spark uses Akka basically for scheduling. All the workers request for a task to master after registering. The master just assigns the task. Here Spark uses Akka for messaging between the workers and masters.

  • Question: Explain About The Core Components Of A Distributed Spark Application.?

    Answer :

    Driver: The process that runs the main () method of the program to create RDDs and perform transformations and actions on them.

    Executor: The worker processes that run the individual tasks of a Spark job.

    Cluster Manager: A pluggable component in Spark, to launch Executors and Drivers. The cluster manager allows Spark to run on top of other external managers like Apache Mesos or YARN.

  • Question: How Can You Achieve High Availability In Apache Spark?

    Answer :

    • Implementing single node recovery with local file system
    • Using StandBy Masters with Apache ZooKeeper.
  • Question: What Is A Sparse Vector?

    Answer :

    A sparse vector has two parallel arrays –one for indices and the other for values. These vectors are used for storing non-zero entries to save space.

  • Question: Why Is There A Need For Broadcast Variables When Working With Apache Spark?

    Answer :

    These are read only variables, present in-memory cache on every machine. When working with Spark, usage of broadcast variables eliminates the necessity to ship copies of a variable for every task, so data can be processed faster. Broadcast variables help in storing a lookup table inside the memory which enhances the retrieval efficiency when compared to an RDD lookup ().

  • Question: What Do You Understand By Lazy Evaluation?

    Answer :

    Spark is intellectual in the manner in which it operates on data. When you tell Spark to operate on a given dataset, it heeds the instructions and makes a note of it, so that it does not forget – but it does nothing, unless asked for the final result.

    When a transformation like map () is called on a RDD-the operation is not performed immediately. Transformations in Spark are not evaluated till you perform an action. This helps optimize the overall data processing workflow.

  • Question: What Is The Significance Of Sliding Window Operation?

    Answer :

    Sliding Window controls transmission of data packets between various computer networks. Spark Streaming library provides windowed computations where the transformations on RDDs are applied over a sliding window of data. Whenever the window slides, the RDDs that fall within the particular window are combined and operated upon to produce new RDDs of the windowed DStream.

  • Question: Name A Few Companies That Use Apache Spark In Production.?

    Answer :

    Pinterest, Conviva, Shopify, Open Table

  • Question: How Can You Minimize Data Transfers When Working With Spark?

    Answer :

    Minimizing data transfers and avoiding shuffling helps write spark programs that run in a fast and reliable manner.

    The various ways in which data transfers can be minimized when working with Apache Spark are:

    1. Using Broadcast Variable- Broadcast variable enhances the efficiency of joins between small and large RDDs.
    2. Using Accumulators – Accumulators help update the values of variables in parallel while executing.
    3. The most common way is to avoid operations ByKey, repartition or any other operations which trigger shuffles.
  • Question: Explain About The Major Libraries That Constitute The Spark Ecosystem?

    Answer :

    Spark MLib- Machine learning library in Spark for commonly used learning algorithms like clustering, regression, classification, etc.

    Spark Streaming – This library is used to process real time streaming data.

    Spark GraphX – Spark API for graph parallel computations with basic operators like joinVertices, subgraph, aggregateMessages, etc.

    Spark SQL – Helps execute SQL like queries on Spark data using standard visualization or BI tools.

  • Question: How Can You Remove The Elements With A Key Present In Any Other Rdd?

    Answer :

    Use the subtractByKey () function.

  • Question: How Can You Trigger Automatic Clean-ups In Spark To Handle Accumulated Metadata?

    Answer :

    You can trigger the clean-ups by setting the parameter ‘spark.cleaner.ttl’ or by dividing the long running jobs into different batches and writing the intermediary results to the disk.

  • Question: What Is Catalyst Framework?

    Answer :

    Catalyst framework is a new optimization framework present in Spark SQL. It allows Spark to automatically transform SQL queries by adding new optimizations to build a faster processing system.

  • Question: What Are The Disadvantages Of Using Apache Spark Over Hadoop Mapreduce?

    Answer :

    Apache spark does not scale well for compute intensive jobs and consumes large number of system resources. Apache Spark’s in-memory capability at times comes a major roadblock for cost efficient processing of big data. Also, Spark does have its own file management system and hence needs to be integrated with other cloud based data platforms or apache hadoop.

  • Question: Explain About The Different Types Of Transformations On Dstreams?

    Answer :

    Stateless Transformations:- Processing of the batch does not depend on the output of the previous batch.

    Examples: map (), reduceByKey (), filter ().

    Stateful Transformations:- Processing of the batch depends on the intermediary results of the previous batch.

    Examples: Transformations that depend on sliding windows.

  • Question: How Can You Compare Hadoop And Spark In Terms Of Ease Of Use?

    Answer :

    Hadoop MapReduce requires programming in Java which is difficult, though Pig and Hive make it considerably easier. Learning Pig and Hive syntax takes time. Spark has interactive APIs for different languages like Java, Python or Scala and also includes Shark i.e. Spark SQL for SQL lovers – making it comparatively easier to use than Hadoop.

  • Question: What Is Lineage Graph?

    Answer :

    The RDDs in Spark, depend on one or more other RDDs. The representation of dependencies in between RDDs is known as the lineage graph. Lineage graph information is used to compute each RDD on demand, so that whenever a part of persistent RDD is lost, the data that is lost can be recovered using the lineage graph information.

  • Question: How Spark Handles Monitoring And Logging In Standalone Mode?

    Answer :

    Spark has a web based user interface for monitoring the cluster in standalone mode that shows the cluster and job statistics. The log output for each job is written to the work directory of the slave nodes.

  • Question: What Are The Common Mistakes Developers Make When Running Spark Applications?

    Answer :

    Developers often make the mistake of:-

    1. Hitting the web service several times by using multiple clusters.
    2. Run everything on the local node instead of distributing it.
    3. Developers need to be careful with this, as Spark makes use of memory for processing.
  • Question: How Can Spark Be Connected To Apache Mesos?

    Answer :

    To connect Spark with Mesos:

    1. Configure the spark driver program to connect to Mesos. Spark binary package should be in a location accessible by Mesos. (or)
    2. Install Apache Spark in the same location as that of Apache Mesos and configure the property ‘spark.mesos.executor.home’ to point to the location where it is installed.
  • Question: Why Is Blinkdb Used?

    Answer :

    BlinkDB is a query engine for executing interactive SQL queries on huge volumes of data and renders query results marked with meaningful error bars. BlinkDB helps users balance ‘query accuracy’ with response time.

  • Question: Explain About Transformations And Actions In The Context Of Rdds.?

    Answer :

    Transformations are functions executed on demand, to produce a new RDD. All transformations are followed by actions. Some examples of transformations include map, filter and reduceByKey.

    Actions are the results of RDD computations or transformations. After an action is performed, the data from RDD moves back to the local machine. Some examples of actions include reduce, collect, first, and take.

  • Question: How Can You Launch Spark Jobs Inside Hadoop Mapreduce?

    Answer :

    Using SIMR (Spark in MapReduce) users can run any spark job inside MapReduce without requiring any admin rights.

  • Question: Is Apache Spark A Good Fit For Reinforcement Learning?

    Answer :

    No. Apache Spark works well only for simple machine learning algorithms like clustering, regression, classification.

  • Question: What Is Shark?

    Answer :

    Most of the data users know only SQL and are not good at programming. Shark is a tool, developed for people who are from a database background – to access Scala MLib capabilities through Hive like SQL interface. Shark tool helps data users run Hive on Spark – offering compatibility with Hive metastore, queries and data.

  • Question: Define A Worker Node.?

    Answer :

    A node that can run the Spark application code in a cluster can be called as a worker node. A worker node can have more than one worker which is configured by setting the SPARK_ WORKER_INSTANCES property in the spark-env.sh file. Only one worker is started if the SPARK_ WORKER_INSTANCES property is not defined.

  • Apache Spark Questions and Answers for Interview

    Preparing for Apache Spark job interview and whether you’re experienced or fresher & don’t know what kind of questions will be asked in Apache Spark interview, then go through the above 100+ Top Apache Spark Interview Questions and Answers to crack your job interview.