Showing posts with label servers. Show all posts
Showing posts with label servers. Show all posts

December 30, 2021

Top 20 Apache Tapestry Interview Questions and Answers


                Do you want to succeed in the Apache Tapestry and advance your career? Then, on this page, we will offer you with the complete set of Apache Tapestry job Interview Questions and Answers. Apache Tapestry is a Java-based open source web framework. It's a web framework that's built around components. Apache Tapestry is a framework for building extremely scalable web applications. Many top firms offer Apache Tapestry jobs in a variety of positions. In the Java programming language, there are more opportunities for experienced workers. Job hunting may be difficult and exhausting, especially if you don't know how to apply, where to look, or how to prepare for job interviews. To minimise any misunderstanding, we've framed Apache tapestry job interview questions and answers to help you prepare for your interview.

 Apache Hive Interview Questions & Answers

Ques. 1): How do I run multiple Tapestry applications in the same web application?


Multiple Tapestry 5 apps are not supported; there is only one place to identify the application root package, therefore configuring multiple filters into multiple directories isn't an option.

Tapestry 5 did not include support for numerous Tapestry applications in the same web application (it needlessly complicated Tapestry 4). Given how disjointed Tapestry 5 pages are, there doesn't appear to be a benefit to doing so... and, if it were possible, there would be a considerable drawback in terms of memory use.

You can run Tapestry 4 and Tapestry 5 apps side by side (the package names are different for this reason), but they have no knowledge of each other and are unable to interact directly. This is just like the way you could have a single WAR with multiple servlets; the different applications can only communicate via URLs, or shared state in the HttpSession.

 Apache Ambari interview Questions & Answers

Ques. 2): Tapestry focuses on the wrong field in my form, how do I fix that?


Tapestry usually determines which field in your form should receive initial emphasis by giving a FieldFocusPriority to each field as it renders, which translates to the following logic:

There is an error in the first field.

Alternatively, the first mandatory field

Alternatively, the first field

Due to a variety of reasons beyond Tapestry's control, its choices may not always be exactly what you desire, necessitating the use of an override. The data is kept track of in the JavaScriptSupport environment. It's simply a matter of injecting the component to get its client id, then notifying JavaScriptSupport of your override.

Here's an example

 <t:textfield t:id="email" t:mixins="OverrideFieldFocus" .../>

The OverrideFieldFocus mixin forces the email field to be the focus field, regardless.

 Apache NiFi Interview Questions & Answers

Ques. 3): Is Tapestry A Jsp Tag Library?

Answer :

Tapestry is not a JSP tag library; it is based on the servlet API but does not make use of JSPs. It has its own rendering engine and HTML template format. Tapestry now offers a simple JSP tag library in release 3.0, allowing JSP pages to link to Tapestry pages.

Apache Spark Interview Questions & Answers

Ques. 4): I Have A Form With A Submit Button. On The Form And The Submit Button Are Two Separate Listeners. Which Is Invoked First?

Answer :

While the shape encounters your button at some time throughout the rewind, the button's listener must be called. The form's submitListener must be called after the shape has completed its rewind, therefore different listeners were called in either scenario. Note that this could mean that the listener for a button can be called before the form has'submitted' all of its values; it all depends on where your input fields are in relation to your button.


Ques. 5): Is There A Wysiwyg Editor For Tapestry, Or An Ide Plugin?

Answer :

Tapestry currently lacks a WYSIWYG editor; nonetheless, the nature of Tapestry allows existing editors to function reasonably well (Tapestry additions to the HTML markup are virtually invisible to a WYSIWYG editor). Spindle is a Tapestry plugin for the Eclipse IDE, which is free and open-source. Tapestry apps, pages, and components may now be created using wizards and editors.


Ques. 6): How Is The Performance Of Tapestry?

Answer :

Other testing (recorded in the Tapestry discussion boards) coincides with my own testing, which was published in the September 2001 issue of the Java Report: Although plain JSPs have a minor advantage in demo applications, performance curves for equal Tapestry and JSP applications with a database or application server backend are identical. Consider the performance of your Java developers rather than the performance of Tapestry.


Ques. 7): What’s The Lifecycle Of A Form Submit?

Answer :

Events will trigger in the following order:





The form "rewind" cycle is simply a render cycle with the output buffered and scraped instead of being written to the servlet output stream. The second pageBeginRender() is called while the page is being rendered. To distinguish between these two render cycles, use requestCycle.isRewinding().


Ques. 8): Does Tapestry Work With Other Other Application Servers Besides Jboss?

Answer :

Yes, of course! For the turn-key demonstrations, JBoss is free and convenient. In less than a minute, you can download Tapestry and JBoss and have a real J2EE application running! JBoss configuration scripts are specific to a specific release of JBoss, which must be 3.0.6. Tapestry apps, on the other hand, are completely container agnostic... Tapestry is unconcerned with the servlet container it's in, and it doesn't even require an EJB container.


Ques. 9): Can I Use The Same Component Multiple Times In One Template?


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”/>


Ques. 10): Why is @script required in Apache Tapestry?


The script framework is a useful tool for grouping scripts into components. It delivers the benefits of components to scripts. It may now be utilised as a component without having to bother about renaming field names or rewiring the fields and scripts. All you have to do now is declare the component and you're ready to go. It is true that another layer of abstraction must be acquired, but once learned, it is extremely powerful. And, to tell you the truth, there isn't much to it.

The script framework is required since form element/field names are produced automatically by the framework. As a result, you write your script in XML, assigning these names to variables, and relying on the framework to deliver the correct names at runtime. Further, you can request that the framework include extra objects that will aid in the creation of your script.


Ques. 11): When a form is submitted, why does Tapestry send a redirect?


This is a variant of the Post/Redirect/Get strategy. It ensures that if a user resubmits the resultant page after an operation that alters server-side state, such as a form submission, the operation is not repeated; instead, only the results of the operation, reflecting the updated server-side state, are re-rendered.

This has the unwelcome consequence of requiring any data required to produce the answer to persist between the event request (the form submission) and the render request; this frequently necessitates the use of @Persist annotations on fields.


Ques. 12): When I utilise an HTML object like &nbsp; in my template, why do I get a SAXParseException?


Tapestry reads your templates using a regular SAX parser. This means that your templates must be well-formed, with balanced open and close tags, quoted attribute values, and defined entities. The simplest method to do this is to include a DOCTYPE at the top of your template:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"


Part of the DOCTYPE is the declaration of entities such as &nbsp;.

You can also use the numeric version: &#160; This is the exact same character and will render in the browser identically. When no doctype is present, Tapestry adds an XHTML doctype; this ensures that common HTML entities behave properly.


Ques. 13): When I submit a form, I get an error message that says "Tapestry is undefined." Why?


This client-side mistake is obvious, yet it can be difficult to resolve. It implies your browser was unable to correctly load the tapestry.js file. Why, exactly, is the question? It could be for a variety of causes, some of which are listed below:

Check to see if 'tapestry.js' is present in the head section of your HTML page.

Tapestry generates a single URL to get all the JS files if the tapestry.combine-scripts configuration parameter is set to true. This can sometimes result in long URLs that browsers are unable to get. Set the sign to false and see what happens.

If you use jQuery in conjunction with Tapestry's prototype, the '$' selection used by both will clash. Put jQuery on top of the stack and enable the jQuery.noConflict mode in this scenario.

Also, if you've added a custom or third-party JS library to the stack and it's causing the JavaScript parsing to fail, look at the JavaScript syntax in that library.

If you used a programme to compress your JavaScript libraries, it's possible that you'll get JavaScript syntax issues, so make sure it works with all of the JavaScript files unpacked.


Ques. 14): Do I have to specify both id and t:id for Zone components?


The Zone component's examples (in the Component Reference) always give both id and t:id, which is definitely a good thing.

In general, the client-side id (the id attribute) will be the same as the Tapestry component id if you don't define it (t:id).

There are, however, numerous exceptions to this rule. It's possible that the Zone is rendering inside a Loop (in which case, each rendering will have a unique client side id). A random unique id is added into the id if the Zone is rendering as part of a partial page render. Tapestry component ids in nested components can potentially clash in other situations.


Ques. 15): When rendering an empty Zone, why do I get the exception "The produced content did not include any components that allow for the positioning of the concealed form field's element."?


Tapestry must write a hidden input element with information needed when the form is submitted as part of its form processing. Because the content of a Zone can be altered or erased, a hidden field separate from the rest of the enclosing form is established solely for the Zone.

At the same time, Tapestry wants to position the <input> field in a valid location, and HTML defines some constraints for that; an input field must appear inside a <p> or <div> element. If your zone is initially empty, there's no place to put the hidden element, and Tapestry will complain.

The solution is simple: just add a <div> element to the body of the zone. This ensures that there's a place for the hidden input field.  An empty <div> element (even one containing a hidden form field) will not affect page layout.


Ques. 16): Why is it necessary for me to provide an interface for my services? Why can't I simply use the class?


To begin with, you can do just this, but you will lose some of the functionality provided by Tapestry's IoC container.

Tapestry will be able to provide functionality for your service around the core service implementation as a result of the split. This is accomplished by using proxies, which are Java classes that implement the service interface. The proxy's methods will eventually call the methods of your service implementation.

One of the most important functions of proxies is to encapsulate the life cycle of a service: most services are singletons that are built just once. Just in time refers to the moment you call a method. What's going on is that the life cycle proxy (the object that gets injected into pages, components or other service implementations) checks on each method invocation to see if the actual service exists yet. If not, it instantiates and configures it (using proper locking to ensure thread safety), then delegates the method invocation to the service.

If you bind a service class (not a service interface and class), then the service is fully instantiated the first time it is injected, rather than at that first method invocation. Further, you can't use decorations or method advice on such a service. The life cycle proxy (the object injected into pages, components, and other service implementations) examines each method invocation to determine if the actual service has been created yet. If it isn't already instantiated and configured (with suitable locking to ensure thread safety), it delegated method invocation to the service.

When you bind a service class (rather than a service interface and class), the service is fully instantiated the first time it is injected, rather than when the first method is invoked. Furthermore, such a service does not allow for the use of decorations or technique suggestions.

The final reason for the service interface / implementation split is to nudge you towards always coding to an interface, which has manifest benefits for code structure, robustness, and testability.


Ques. 17): How do I make my service startup with the rest of the application, rather than lazily?


Tapestry services are designed to be lazy; they are only fully realized when needed: when the first method on the service interface is invoked.

Sometimes a service does extra work that is desirable at application startup: examples may be registering message handlers with a JMS implementation, or setting up indexing. Since the service's constructor (or @PostInjection methods) are not invoked until the service is realized.

The solution is the @EagerLoad annotation; service implementation classes marked with this annotation are loaded when the Registry is first startup, rather than lazily.


Ques. 18): How can I dynamically add new components to an existing page?


You don't, to put it succinctly. The long answer is that you don't have to in order to achieve the desired behaviour.

High scalability is one of Tapestry's core values; it can be expressed in a variety of ways, reflecting scalability concerns both within a single server and across a cluster of servers.

Although you code Tapestry pages and components as if they were ordinary POJOs (Plain Old Java Objects — Tapestry doesn't require you to extend any base classes or implement any special interfaces), they behave more like a traditional servlet when deployed by Tapestry: a single instance of each page serves requests from multiple threads. In the background,


Ques. 19): What this means is that any incoming request must be handled by a single page instance. Therefore, Tapestry enforces the concept of static structure, dynamic behavior.


 Beyond simple conditionals and loops, Tapestry offers a variety of options for varying what content is presented. When rendering a page, you can "drag in" components from other pages (other FAQs will expand on this concept). The idea is that, while the structure of a Tapestry page is quite strict, the order in which the page's components render does not have to be top to bottom.


Ques. 20): Why do my images and stylesheets end up with a weird URLs like /assets/meta/zeea17aee26bc0cae/layout/layout.css?


The servlet container isn't used by Tapestry to serve static assets (images, stylesheets, flash movies, etc.). Tapestry, on the other hand, handles the requests and streams assets to the browser.

The content of the assets will be compressed using GZIP (if the client supports compression, and the content is compressible). Tapestry will also add an expires header to the content in the future. This means the browser will not ask for the file again, resulting in a significant reduction in network traffic.

The strange hex string is a fingerprint; it's a hash code calculated from the asset's real content. If the asset changes, a new fingerprint will be created, as well as a new path and (immutable) resource. This approach, combined with a far-future expires header also provided by Tapestry, ensures that clients aggressively cache assets as they navigate your site, or even between visits.

January 28, 2020

Top 20 Node.js Interview Questions and Answers

               Preparing for the Node js interview questions, you should start with the basic concepts to advanced topics and move up from down. It is important to understand how things work before moving on the more complex topics. To get the best understanding of Node.js, you must have a basic understanding of JavaScript related concepts as well.


Ques: 1. What can be the possible use of DNS module in Node.js?


This is one of the most asked Node js interview questions. The DNS module consists of an asynchronous network wrapper. Let’s have a look at the most commonly used functions of this module:

1. DNS.lookup(address, options, callback) – This method takes any website’s address as its first parameter and returns the corresponding first IPV4 or IPV6 record. The options parameter can be an integer or object. If no options are provided both IPV4 and IPV6 are valid inputs. The third parameter is the callback functions.

2. DNS.lookupservice(address, port, callback) – This function converts any physical address to an array of record types. The record types are specified by the second parameter, rrbyte. The third method is the callback function.

3. dns.getServers() – This function returns an array of IP address strings that are currently configured for DNS resolution, formatted according to rfc5952. A string will include a port section if a custom port is used.

4. DNS.setServers() – This function sets the IP address and port of servers to be used when performing DNS resolution. The DNS.setServers() method must not be called while a DNS query is in progress.

AngularJS Interview Questions and Answers

Ques: 2. How can you use Timers in Node.js?


As the name suggests, the Timer module executes code after a set period of time. It doesn’t need to be imported via require(). All the methods are available globally to emulate the browser JavaScript API which provides several ways of scheduling code to execute at a certain time.

The functions provided by Node.js for Timers are:

setTimeout(), setImmediate(), and setInterval.

AJAX interview Questions and Answers

Ques: 3. What do you mean by non-blocking mean in Node.js?


If you are talking about non-blocking in Node.js, you are much aware about the non-blocking I/O.  It can be explained how Node uses libuv to handle its IO in a platform-agnostic way. A non-blocking request is made and upon a request, it queues it within the event loop. The JavaScript callback is then called on the main JavaScript thread.

JavaScript Interview Questions and Answers

Ques: 4. What is the main difference between Node.js and Ajex?


The easiest way to explain the difference between Node.js and Ajax is that Node is a server-side JavaScript, while Ajax is a client-side technology. What that means is that Ajax is often used for updating the contents of the page without refreshing it. Node, on the other hand, is used for developing server software, executed by the server rather than in the browser.

JQuery Interview Questions and Answers

Ques: 5. What are the various pros and cons of Node.js?


Let’s take a look at the most important pros and cons:


  • In the cases when your app doesn’t have any CPU intensive computation, you can build the whole thing in Javascript, including the basic database level. All you have to do is use  JSON storage object DB like MongoDB. 
  • Crawlers receive a full-rendered HTML response which is great for SEO.


  • Node.js responsiveness is blocked by an intensive CPU computation so a threaded platform would a better approach in those cases. 
  • Using a relational database with Node.js is considered less favourable.

Advance Java interview Questions and Answers

Ques: 6. What is the use of method spawn() and fork()?


The spawn method is used when a new process is to be launched with a given set of commands. Check out the following command:

child_process.spawn(command[, args][, options])

The fork method is considered to be a special case for spawn() method. The following code shows how to use it:

child_process.fork(modulePath[, args][, options])

Ques: 7. Can you explain the EventEmitter in Node.js?


EventMitter class for event module helps with raising and handling custom events. You can access it with the following code:

// Import events module

var events = require(‘events’);

// Create an eventEmitter object

var eventEmitter = new events.EventEmitter();

Ques: 8. What do you understand by tracing?


The purpose of tracing is to trace information generated by V8. To enable it, pass flag-trace-events-enabled when starting the node.

All recorded categories can be specified by the flag–trace-event categories. The enabled logs can be opened as chrome://tracing in Chrome.


Ques: 9. Can you explain the control flow function and steps to execute it?


The control flow function is the code that runs between asynchronous function calls. Following steps should be followed to execute it: 

  1. Control the order of execution. 
  2. Collect data. 
  3. Limit concurrency. 
  4. Call the next step in the program.


Ques: 10. What is the file system module of Node js?


The file system module performs a file-related operation. It comprises synchronous and asynchronous functions to read/write files.

For instance, readFile() function is asynchronous function to read file content from specified path and readFileSync() is synchronous function to read files.


Ques: 11. What are some of the most popular modules of Node.js?


The most popular modules Nodes.js are:

  • xpress 
  • async 
  • browserify 
  • bower 
  • gulp 
  • grunt


Ques: 12. What do you understand by package.json in node.js? What is it used for?


Package.json holds various metadata information about the project. The information contained in this file is then given to npm to identify the project and to handle its dependencies.  

Some of the fields are name, description, author, and dependencies.

The dependencies are then installed whenever the project is installed through npm. Moreover, if the npm install is run in the root directory of the project, the dependencies will be installed in ./node_modules directory.


Ques: 13. What is the difference between Asynchronous and Non-blocking?


Asynchronous or simply not synchronous means that the HTTP requests are not waiting for the server response. You can continue with other block and respond to the server response when received.

Non-Blocking, on the other hand, is a term commonly used with IO. For instance, non-blocking read/write calls return and expect the caller to call again. Read will wait until it has some data and put calling thread to sleep.

Ques: 14. What are the features of Node.js?


Since the APIs of Node.js library are asynchronous, they are non-blocking which means that a Node.js based server never waits for an API to return data. Node.js is a system built on Google Chrome’s V8 JavaScript Engine which makes it very fast.

This system uses a single threaded model with event looping. With the event mechanism helping the server respond in a non-blocking way, the server is highly scalable compared to the other servers that create limited threads to handle requests.


Ques: 15. Why should you use Node.js?


One could use Node.js when they want to easily build scalable apps. The biggest pros include:

  • It is very fast in code execution.
  • It is asynchronous and event-driven.
  • It is single-threaded but highly scalable.
  • No buffering.

Ques: 16. Explain the role of REPL in Node.js.?


REPL stands for Read, Evaluate, Print, Loop – and it performs all the mentioned tasks accordingly. It is used to execute ad-hoc JavaScript statements and it is a very important part of the testing and debugging process.


Ques: 17. What is libuv library? And what is its use in Node.js?


Libuv is a multi-platform support library with a focus on asynchronous I/O. Although it was primarily developed for Node.js, it’s also commonly used by other systems such as Luvit, Julia, pyuv etc.

Back in the days when the whole Node project started, it was using Google’s V8 and Marc Lehmann’s libev. However, the problem with libev was that it ran only on Unix so they had to come up with the new solution to make it work on Windows, especially once node.js grew in popularity.

Libuv was an abstraction around libev or IOCP depending on the platform, providing users an API based on libev. In the node-v0.9.0 version of libuv, libev was removed.

Here are some of the key features:

  • Full-featured event loop backed by epoll, kqueue, IOCP, event ports. 
  • Asynchronous TCP and UDP sockets. 
  • Asynchronous file and file system operations.
  • Child processes.
  • File system events.

Ques: 18. What are the two arguments that async.queue takes?


These two arguments are:

a)      Task function

b)      Concurrency value


Ques: 19. How to avoid Callback Hell?


Basically, every time a long-running query finishes its execution, the callback associated with the query is run. Since Node.js uses single thread only, it happens that it leads to numerous queued events. And that is where the callback comes in.

There are 4 common solutions for this issue:

Modular code – the code split into smaller modules that are later joined together to the main module again

Promise mechanism – ensures either a result or error; it’s an alternative way for the async code and it takes two optional arguments, one of which is called depending on the state of promise

Use of generators – they wait and resume using the yield keyword but can also suspend and resume async operations.

Async mechanism – the module with <async.waterfall> API which passes data from one operation to another using the next callback.


Ques: 20. What isNPM?


NPM stands for Node Package Manager. It has 2 important functions:

It works on Online Repository for packages which are present at <>. In addition to that, it also works as a command line utility and does version management.

You can verify version using below command: npm –version.

To install any module you can use: npm install <Module Name>