struts 1.x interview que with ans

Upload: mkmartha

Post on 06-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Struts 1.x Interview Que With Ans

    1/26

    Ques: 1 What're the types of controllers?Ans:There are two types of Controllers in Strus.

    1.Main Controller/FrontControllerEx: ActionServlet

    2.Application ControllerEx:Action Class

    Ques: 2 What is the Struts 2.0 flow?Ques: 3 How do we config struts config file in spring configuration file?Ques: 4 Is actionform belongs to the model or view or controller in struts? Ques: 5 what are responsibilities of a struts action class?which responsibility is view relatedaspect of boundary component?Does it provide any facilities for separating these view relatedaspects for the controller related action classes?

    Ques: 6 Is Struts compatible with other Java technologies?Ans:Yes. Struts is committed to supporting industry standards. Struts acts as an integrator of Javatechnologies so that they can be used in the "real world".

    Ques: 7 How you will enable front-end validation based on the xml in validation.xml?

    Ans:The tag to allow front-end validation based on the xml in validation.xml. For example thecode: generates the client side java script for the form logonForm as defined in the validation.xml file. The when added in the jsp file generates the client site validation script.

    Ques: 8 Explain about the validation steps involved in validation of client side address?Ans:The steps which are to be carried for validating client side address they are:* Validator plug in should be enabled to the system to start the process of validation.* A message resource should be created which can display error message to the client.* Validation rules should be defined by the developer for validation.* Relevant tags should be created to generate Java script code.

    * The whole process of validation should be tested.

    Ques: 9 What is LookupDispatchAction?Ans:The LookupDispatchAction is an abstract Action that dispatches to the subclass mapped execute method.This is useful in cases where an HTML form has multiple submit buttons with the same name. The buttonname is specified by the parameter property of the corresponding ActionMapping.

    Ques: 10 How you will make available any Message Resources Definitions file to the StrutsFramework Environment?Ans:Message Resources Definitions file are simple .properties files and these files contains the messages thatcan be used in the struts project. Message Resources definitions files can be added to the struts-

    config.xml file using the tag.Example:

    Ques: 11 Describe the details of XML files used in the Validator Framework?

    Ans:The Validator Framework uses two XML configuration files:* validator-rules.xml and* validation.xml.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    2/26

    The validator-rules.xml defines the standard validation routines. These are reusable and used invalidation.xml to define the form specific validations. The validation.xml defines the validations applied toa form bean.

    Ques: 12 Can I have an Action without a form?Ans:Yes! If your Action does not need any data and it does not need to make any data available to the view orcontroller component that it forwards to, it doesn't need a form.A good example of an Action with no ActionForm isthe LogoffAction in the struts example application.

    Ques: 13 What are the JSTL and JavaServer Faces ?Ans:JSTL, the JavaServer Standard Tag Library, is a set of JSP tags that are designed to make it easier todevelop Web applications. JavaServer Faces (JSF) is a specification for a new technology that promisesto make it easier to write MVC applications, both for the Web and for the desktop. Both JSTL and JSF arecomplementary to Struts.

    Ques: 14 How can we work struts on Eclipse? What is the best plugin for this?Ans:

    Eclipse provides option to any web project. Building struts applicationbecomes very easy with the GUI provided and drag drop feature of struts-config file. The best plug-inavailable for this is My-ecllipse.

    Ques: 15 What are the disadvantages of struts?Ans:Disadvantages of Struts:* Bigger Learning Curve. To use MVC with Struts, you have to be comfortable with the standard JSP

    and servlet APIs and a large and elaborate framework that is almost equal in size to the core system.* Worse Documentation. Compared to the standard servlet and JSP APIs, Struts has fewer online

    resources, and many first-time users find the online Apache documentation confusing and poorlyorganized.* Less Transparent. Struts applications are: Harder to understand and Harder to benchmark and

    optimize.* Rigid Approach. The flip side of the benefit that Struts encourages a consistent approach to MVC is

    that Struts makes it difficult to use other approaches.

    Ques: 16 How you will save the data across different pages for a particular client request usingStruts?Ans:You can use the session object to save the data across different pages for a particular client requestusing Struts.Create an appropriate instance of ActionForm that is form bean and store that form bean in sessionscope. So that it is available to all the pages that for a part of the request.

    request.getSession()

    session.setAttribute()

    Ques: 17 What is the purpose of tiles-def.xml file, resourcebundle.properties file, validation.xmlfile?Ans:A tiles-def.xml is used as a configuration file for an appliction during tiles development. You can definethe layout, header, footer, body content for your View.The validation.xml file is used to declare sets of validations that should be applied to Form Beans. EachForm Bean you want to validate has its own definition in this file. Inside that definition, you specify thevalidations you want to apply to the Form Bean's fields.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    3/26

    Instead of having hard-coded error messages in the framework, Struts Validator allows you to specify akey to a message in the ApplicationResources.properties (or resourcebundle.properties) file that shouldbe returned if a validation fails.

    Ques: 18 Explain about token feature in Struts?Ans:The problem of duplicate form submission arises when a user clicks the Submit button more than oncebefore the response is sent back. This may result in inconsistent transactions and must be avoided.In Struts this problem can be handled by using the saveToken() and isTokenValid() methods of Actionclass. saveToken() method creates a token (a unique string) and saves that in the user's current session,while isTokenValid() checks if the token stored in the user's current session is the same as that waspassed as the request parameter.

    Ques: 19 What is the difference between Apache struts and Jakarta Struts? why there are 2names?Ans:Both apache struts and jakarta struts are one and the same. Struts was originally created by CraigMcClanahan and was donated to the Apache Foundation in May, 2000. Its evolve as a Jakarta Project, inearly 2004 it become an official Apache Project.

    Ques: 20 What is the super class of Action and ActionForm?Ans:There is no immediate super class for Action and Action Form, Object class is the super class for Actionand ActionForm.

    Ques: 21 How the container will know this is a struts application?Ans:The web container do not need to know about the design pattern we used in our application. Our Strutsapplication is deployed in the web.xml file. The container reads the web.xml file, and acts accordingly.

    Ques: 22 Can I have more than one struts-config.xml file for a single Struts application?Ans:Yes! One can have more than one struts-config.xml file for a single Struts application. You can define

    different struts-conifg.xml file for different modules in a single web application. It is useful when you aredeveloping a distributed application.But you must enter those struts-config.xml files details in deployment descripter (i.e., web.xml) file.

    Example: config/WEB-INF/struts-first-config.xml,/WEB-INF/struts-second-config.xml,/WEB-INF/struts-third-config.xml

    Here three struts configutation files are deployed in a single application.

    Ques: 23 Should every html form property have a corresponding formbean get/set and variable.?Ans:Yes! Every html form property must have a corresponding FormBean get/set methods. Otherwise you'llget an error.

    Ques: 24 What are the contents of web.xml and struts-config.xml? What is the difference betweenthem? How to relate these tow xml files?Ans:A web.xml file is the DD (deployment descriptor) for any web based application while struts-config.xml isfor specifically struts based application. A web.xml file establishes connection between application and

  • 8/3/2019 Struts 1.x Interview Que With Ans

    4/26

    container whereas struts-config.xml bridges gap between view and controller. A web.xml file is read bycontainer when we start the container. struts-config.xml file is used by init() method of ActionServlet.

    Ques: 25 What is difference between Html tags and Struts specific HTML TagsAns:Struts tags bind the property value with the Formbean property defined. HTML tags are static and Strutstags are dynamic.

    Ques: 26 Is Action class is Servlet or Not ? if yes why ?Ans:Action class extents org.apache.struts.action.Action which has nothing to do with Servlet. Its a plain javaclass which is been called/Managed by a well defined framework called Struts.

    Ques: 27 What are the core classes of Struts?Ans:The core classes of Struts are:* Action,* ActionForm,* ActionServlet,* ActionMapping,

    * ActionForward, etc.

    Ques: 28How can we communicate from struts to ejb?Ans:The ActionClass overrides execute() method.Then in body of execute() method:* Get Initial Context* Get home object using JNDI look up.* Create the bean and call the business methods.

    Ques: 29 What will happen if the mapping to actionform in the struts-config.xml is mentionedwrong?Ans:

    An excetion will be thrown. If we try to cast the action form and using it, then it will throw nullpointerexception.Ans:It will give an exception that, properties not found which are used in the front end(jsp)

    Ques: 30 Why was perform() method changed as execute() method in Action class?Ans:The Action.perform() is the method called by the ActionServlet defined in Struts 1.x and declares that itthrows only IOException and ServletException. To support declarative exception handling, the method'ssignature changed in perform() and it becomes the execute() method in the Struts 2.x. This is typicallywhere your business logic resides.

    Ques: 31 What is the difference between Struts 1.x and Struts 2.x

    Ans:The difference between Struts 1.x and Struts 2.x:

    * Struts 1.x extends the abstract base class by its action class. The problem with struts1 is that it usesthe abstract classes rather than interfaces. While in Struts 2.x, an Action class implements an Actioninterface, along with other interfaces use optional and custom services.* Struts 1.x Actions are singletons therefore they must be thread-safe because only one instance of a

    class handles all the requests for that Action. Struts 2.x doesn't have thread-safety issues as Actionobjects are instantiated for each request. A servlet container generates many throw-away objects perrequest, and one more object does not impose a performance penalty or impact garbage collection.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    5/26

    * In Struts 1.x Actions are dependent on the servlet API because HttpServletRequest andHttpServletResponse is passed to the execute method when an Action is invoked. Container does nottreat the Struts 2 Actions as a couple. Servlet contexts are typically represented as simple Maps thatallow Actions to be tested in isolation. Struts 2 Actions can still access the original request and response,if required.* Struts 1 binds objects into the page context by using the standard JSP mechanism. Struts 2 uses a

    ValueStack technology to make the values accessible to the taglibs without coupling the view to theobject to which it is rendering.

    Ques: 32 why do we have only one ActionServlet in Struts?Ans:The Struts Framework provides us the cetralised control throughout the web application. We use theActionServlet as a centralised controller. The ActionServlet takes care of all the request and direct it tothe requested resourse. Using the more than controller doing the same thing leads to the duplicacy andredudndancy in your code. Hence there is no need to use more than one controller in a web application.That is why Struts uses the concept of a single Servlet controller.

    Ques: 33 What is heirarchy of files in Struts?Ans:The heirarchy of files depends upon Struts-config.xml that plays an important role in struts framework and

    it is used mainly to have an access to various Action classes using the Action-mapping element and thento forward it to appropriate jsp files. The struts tag libraries include Bean tag, Template tag, Tiles tag,Logic tag, and HTML tag libraries.

    Ques: 34 Why we use Struts framework in project?Ans:Struts framework follow the Model-View-Controller design pattern. Struts framework provides thecentralised control to throughout the Web application. If the application is big like any banking applicationetc, then you should use Struts as it is very robust, makes the things simple, it also has lot of readilyavailable security features.

    Ques: 35 What is the use of tag defined by Bean tag library in Struts framework?Ans:

    The tag is used to retrieve and print the value of a named bean property. If the formatattribute is encountered, then the value being written will be formatted based upon the format stringrepresented by the format attribute.The tag has no body and supports nine attributes:bundle, filter, format, formatKey, ignore, locale, name, property, scope.

    Example:

    Ques: 36 What is the use of tag defined by Bean tag library in Struts framework?Ans:The tag is used to copy a specified Struts internal component into a paged scopedscripting variable. The Struts components that can be retrieved include a FormBean, a forward, or

    mapping object. The tag has no body and supports four attributes:id, formBean, forward, mapping.

    Example:

    Ques: 37 What is the use of tag defined by Bean tag library in Struts framework?Ans:The tag is used to retrieve the number of elements contained in a reference to an array,

  • 8/3/2019 Struts 1.x Interview Que With Ans

    6/26

    collection, or map. The results of the tag\'s evaluation is a scripting variable of typejava.lang.Integer that contains the number of elements in that collection.The tag has no body and supports five attributes: id, collection, name, property and scope.

    Example:

    Ques: 38 What is the use of tag defined by Bean tag library in Strutsframework?Ans:The tag is used to retrieve the value of Web application resource identified by the nameattribute; the tag makes the resource available as either a java.io.InputStream or a java.lang.String object,based on the value of the input attribute.The tag has no body and supports three attributes: id, name, input.

    Ques: 39 What is the use of tag defined by Bean tag library in Strutsframework?Ans:The tag is used to retrieve the value of a request paremeter identified by the nameattribute. The retrieved value will be used to define a page scoped attribute to type java.lang.String or

    String[], if the multiple attribute is not null. The tag has no body and supports fourattributes:id, name, multiple, value.Example:

    Ques: 40 What is the use of tag defined by Bean tag library in Struts framework?Ans:The tag is used to retrieve the value of an identified implicit JSP object, which it stores inthe page context of the current JSP. The tag has no body and supports two attributes: idand property.

    Example:

    Ques: 41 What is the use of tag defined by Bean tag library in Strutsframework?Ans:The tag is a very useful tag that we can employ to retrieve keyed values from apreviously defined resource bundle. It also supports the ability to include parameters that can besubstituted for defined placeholders in the retrieved string. The tag has no body andsupports 11 attributes:arg0, arg1, arg2, arg3, arg4, bundle, key, locale, name, property, scope.

    Example:

  • 8/3/2019 Struts 1.x Interview Que With Ans

    7/26

    Ques: 42 What is the use of tag defined by Bean tag library in Struts framework?Ans:The tag is used to evaluate and retrieve the results of a web application resource. Thetag makes the response data available as an object of type String.The resource being evaluated by the tag can be identified using three different attributes:forward, href, page.The tag has no body and supports six attributes:id, achor, forward, href, page, transaction.

    Example:

    Ques: 43 What is the use of tag defined by Bean tag library in Struts framework?Ans:The tag functions exactly like , except that it retrieves its values from thenamed request header. Once the tag has the header values, it creates a java.lang.String or

    java.lang.String[] attribute and stores it in the pageContext.If the named header cannot be located and no default value is given, then a request-time exception willbe thrown. The tag has a body type of JSP and supports four attributes:id, name, multiple, value.

    Example :

    Ques: 44 What is the use of tag defined by Bean tag library in Struts framework?Name all of its attribute?Ans:The tag is used to retrieve the value of a named bean property and define it as a scriptingvariable, which is will be stored in the scope specified by the toScope attribute. The retrieved object willperform type conversion on the returned property value, unless it is a Java primitive type, in which case itis wrapped in the appropriate wrapper class.

    This tag has a body type of JSP and supports seven attributes:id, name, property, scope, toScope, type, value.

    Welcome:

    Ques: 45 What is the use of tag defined by Bean tag library in Struts framework?Ans:The tag is used to retrieve the value of an HTTP cookie. It can be used to retrieve singleor multiple cookie values. The retrieved cookie(s) are stored in a page scoped attribute of type Cookie. Ifthe named cookie is not found and no default value is specified, then a request-time exception is thrown.The tag has no body and supports four attributes:id, name, multiple, value.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    8/26

    Ques: 46 What are the steps involved in installing the Bean tag library in your Struts application?Ans:To use Bean tag library in web application, You must complete the following steps:* Copy the TLD file packaged with this tag library, struts-bean.tld, to the webapps/MyAppName/WEB-

    INF directory.* Make sure that the struts.jar file is in the webapps/MyAppName/WEB-INF/lib directory.* Add the following sub-element to the web.xml file of the Web application:/WEB-INF/struts-bean.tld/WEB-INF/struts-bean.tld

    You must add the following taglib directive to each JSP that will leverage the HTML tag library:

    Ques: 47 What is the use of tag defined by Template tag library in Strutsframework?Ans:The tag is used to retrieve and insert the contents of the named URI. The tag acts as the parent to one or more tags, which act as paremeters

    to the named template JSP. The tag has a body type of JSP and a single requiredattribute template that names the URI of the resource to include as the template.

    Ques: 48 What is the use of and tag defined by Template taglibrary in Struts framework?

    Ans:The tag is used to retrieve the contenes of a bean stored in the request scope, with theintention of replacing the tag instance with the contents of the retrieved bean. It is used to define theactual template JSP that will be referenced by the tag. The bean being retrieved isassumed to have been placed on the request by a tag. The tag has nobody and suppots three attributes:* name : Identifies the name of the request attributes to be retrieved. The name attribute should match

    the name of name attribute of the tag.(Required)* role : Specifies the role in which the user must exist for this tag to be evaluated.* If set to true, results in the flushing of the response buffer prior to the inclusion of the specified request

    attribute.

    The tag is used to store the content of a particular URL or text (URI or text) into the

    request scope. This tag is the parent to one or more put tags. The put tags specify the content to beinserted into the template. The layout the content is determined by get tags placed in the template. The tag has no body and supports four attribute:* name : Identifies the name of the attribute to be stored in the request.* role : Specifies the role in which the user must exists for this tag to be evaluated.* content : Specifies the content that will be stored in the request.* direct : If set to true, indicates that the content attribute or body is printed to the request.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    9/26

    Ques: 49 What are the steps involved in installing the Template tag library in your Strutsapplication?Ans:To use Template tag library in web application, You must complete the following steps:* Copy the TLD file packaged with this tag library, struts-template.tld, to the

    webapps/MyAppName/WEB-INF directory.* Make sure that the struts.jar file is in the webapps/MyAppName/WEB-INF/lib directory.* Add the following sub-element to the web.xml file of the Web application:/WEB-INF/struts-template.tld/WEB-INF/struts-template.tld

    You must add the following taglib directive to each JSP that will leverage the HTML tag library:

    Ques: 50 What is the use of and tag defined by Logic taglibrary in Struts framework?Ans:The tag evaluates its body if the variable specified by any one of the cookie, header,

    name, parameter, or property attributes is present in the applicable scope. The tag has abody type of JSP and supports eight attributes:cookie, header, name, property, parameter, scope, role, user.

    The tag evaluates its body if the variable specified by any one of the cookie, header,name, parameter, or property attributes is not present in the applicable scope. The tag has a body type of JSP and supports eight attributes:cookie, header, name, property, parameter, scope, role, user.

    Ques: 51 What is the use of and tag defined by Logic tag libraryin Struts framework?Ans:The tag evaluates its body if the variable specified by any one of the attributes cookie,

    header, name, parameter, or property attributes contains the specified contant value. The tag has a body type of JSP and supports eight attributes:value, location, cookie, header, name, property, parameter, scope.

    The tag evaluates its body if the variable specified by any one of the attributes cookie,header, name, parameter, or property does not contain the specified contant value attribute. The tag has a body type of JSP and supports eight attributes:value, location, cookie, header, name, property, parameter, scope.

    Ques: 52 What is the use of and tag defined by Logic taglibrary in Struts framework?Ans:The tag evaluates its body if the variable specified by any one of the attributes cookie,

    header, name, parameter, or property, is less than or equal to the constant value specified by the valueattribute. The tag has a body type of JSP and supports seven attributes:value, cookie, header, name, property, parameter, scope.

    The tag evaluates its body if the variable specified by any one of the attributes cookie,header, name, parameter, or property, is less than the constant value specified by the value attribute. The tag has a body type of JSP and supports seven attributes:value, cookie, header, name, property, parameter, scope.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    10/26

    Ques: 53 What is the use of tag defined by Logic tag library in Struts framework?Name its attribute?Ans:The tag is used to iterate over a named collection - which contains a Collection,Enumereator, Iterator, Map, or Array - and evaluates its body for each Object in the collection. We canidentify the collection being iterated over by using a request - time expression or a scripting variable. The tag has a body type of JSP and supports nine attributes:id, collection, name, property, scope, type, indexId, length, offset.

    Ques: 54 What is the use of and tag defined by Logictag library in Struts framework?Ans:The tag evaluates its body if the variable specified by any one of the attributescookie, header, name, parameter, or property is greater than or equal to the constant value specified bythe value attribute. The tag has a body type of JSP and supports seven attributes:value, cookie, header, name, property, parameter, scope.

    The tag evaluates its body if the variable specified by any one of the attributescookie, header, name, parameter, or property is greater than the constant value specified by the valueattribute. The tag has a body type of JSP and supports seven attributes:

    value, cookie, header, name, property, parameter, scope.

    Ques: 55 What is the use of tag defined by Logic tag library in Struts framework?Describe its attribute?Ans:The tag uses the HttpServletResponse.sendRedirect() method to redirect the currentrequest to a resource identified by either the forward, href, or page attributes. The taghas no body and supports 12 attributes:* anchor : Used to append an HTML anchor to the end of a generated resource.* forward : Identifies the name of a global forward element that will receive control of the forwarded

    request.* href : Specifies the URL of the resource to forward the current request to.* name : Identifies a scripting variable referencing a java.util.Map object whose collection of key/value

    pairs is used as HTTP request parameters augmenting the redirected request.* property : Identifies a bean property of the bean named by the named attribute.* scope : Defines the scope of the bean specified by the name attribute.* transaction : If set to true, indicates that the current transaction control token should be included in the

    generated URL.* page : Specifies a context-relative path to a resource that will receive control of the current request.* paramId : Identifies the name of the requrest parameter that will be added to the generated URL.* paramName : Specifies a JSP scripting variable, containing a String reference, that represents the

    value for the request parameter named by the paramId attribute.* paramProperty : Identifies a bean propertyof the bean named by paramName attribute.* paramScope : Specifies the scope of the bean specified by the paramName attribute

    Ques: 56 What is the use of and tag defined by Logic tag library

    in Struts framework?Ans:The tag evaluates its body if the variable specified by any one of the attributes cookie,header, name, property, parameter equals the constant value specified by the value attribute. The tag has a body of JSP and supports seven attributes:value, cookie, header, name, property, parameter, scope.Example:

  • 8/3/2019 Struts 1.x Interview Que With Ans

    11/26

    You are exactly at the right age.

    The tag evaluates its body if the variable specified by any one of the attributes cookie,header, name, property, parameter is not equal to the constant value specified by the value attribute. The tag has a body of JSP and supports seven attributes:value, cookie, header, name, property, parameter, scope.Example:You are not at the right age.

    Ques: 57 What is the use of and tag defined by Logic tag libraryin Struts framework?Ans:The tag evaluates its body if either the scripting variable identified by the name attribute ora property of the named scripting variable is equal to null or an empty string. The tag hasa body type of JSP and supports three attributes:

    * name : Identifies the scripting variable being tested.* property : Identifies the data member of the scripting variable ot be tested.(optional)* scope : Defines the scope of the bean specified by the name attribute.

    The tag evaluates its body if either the scripting variable or property of the namedscripting variable is not equal to null or an empty string. The tag has a body type of JSPand supports three attributes:* name : Specifies a scripting variable to be used as the variable being tested.(Required)* property : Specifies the data member of the scripting variable to be tested.(optional)* scope : Defines the scope of the bean specified by the name attribute.

    Ques: 58 What are the steps involved in installing the Logic tag library in your Struts application?Ans:

    To use the Logic tag library in web application, You must complete the following steps:* Copy the TLD file packaged with this tag library struts-logic.tld) to the webapps/MyAppName/WEB-INF

    directory.* Make sure that the struts.jar file is in the webapps/MyAppName/WEB-INF/lib directory.* Add the following sub-element to the web.xml file of the Web application:/WEB-INF/struts-logic.tld/WEB-INF/struts-logic.tld

    You must add the following taglib directive to each JSP that will leverage the HTML tag library:

    Ques: 59 Which tag can be used to initialize the Tiles definition factory in Struts framework?Ans:The tag is used to initialize the Tiles definition factory. This tag isevaluated only once or not at all if the factory has already been initialized by other means. The has no body and supports two attributes:* file : The file containing your Tile definitions.(Required)* classname : The fully qualified classname of the definition factory being initialized. This class, if

    specified, must implement the org.apache.struts.tiles.DefinitionFactory.(Optional)

  • 8/3/2019 Struts 1.x Interview Que With Ans

    12/26

    Ques: 60 Describe the and tags in Tiles tag library inStruts framewrok?Ans:The tag is used to retrieve a Tiles object from the Tiles context and expose thatobject as a scriptlet variable. The tag has no body and supports five attribute:name, id, className, scope, ignore.

    The tag is ues to import a Tiles object from the Tiles context into a JSP scriptletvariable, which is stored in the named scope. If the name and scope attributes are not included are notincluded in the tag instance, then all Tile objects stored in the Tiles context are imported and placed inpage scope. The < tiles:importAttribute/> tag has no body and supports three attributes:name, scope, ignore.

    Ques: 61 What is the use of and tags in Tiles tag library in Strutsframewrok?Ans:The tag is used to add parameters to a parameter as defined by a tag. The tag has a body type of JSP and supports seven attributes:beanName, beanProperty, beanScope, direct, role, type, value.

    The tag is used to retrieve and insert parameters previously defined from the Tiles context.With the exception of ignore attribute being defaulted to true, this tag is functioanlly the same as the. The tag has no body content and support four attributes:name, ignore, flush, role.

    Ques: 62 What is the use of tag in Tiles tag library in Struts framewrok?Ans:The tag is used to define a list of parameters that will passed as attribute to the Tilesobject. The list is created from a collection of child tags. The tag has a bodytype of JSP and supports a single attribute:name : The name of the list being created.(Required)

    Ques: 63 What is for tag used in Tiles tag library in Struts framewrok?

    Ans:The tag is used to define the equivalent of a parameter, representing a sub-component of atemplate, that will be used to the Tiles object. The tag has a body type of JSP and supportseight attribute:name, value, direct, type, beanName, beanProperty, beanScope, role.

    Ques: 64 What is the use of tag in Tiles tag library in Struts framewrok?Ans:The tag is used to create a JavaBean representation of Tiles template definition that isstored in the named scope bound to the identifier named by id attribute. The tag actsmuch like a runtime counterpart to the XML found in the Tiles definition file. The tag has a body type of JSP and supports six attribute:id, scope, template, page, role, extends.

    Ques: 65 What is the use of tag in Tiles tag library in Struts framewrok?Ans:The tag is used to insert a TIles template into a JSP. You must use the or tags to substitute sub-components of the tile being inserted. The tag has abody type of JSP and support 14 attributes:template, components, page, definition, attribute, name, beanName, beanProperty, beanScope, flush,ignore, role, controllerUrl, controllerClass.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    13/26

    Ques: 66 What are the steps involved in installing the Tiles tag library in your Struts application?Ans:To use Tiles tag library in web application, You must complete the following steps:* Copy the TLD file packaged with this tag library struts-tiles.tld to the webapps/MyAppName/WEB-INF

    directory.* Make sure that the struts.jar file is in the webapps/MyAppName/WEB-INF/lib directory.* Add the following sub-element to the web.xml file of the Web application:/WEB-INF/struts-tiles.tld/WEB-INF/struts-tiles.tld

    You must add the following taglib directive to each JSP that will leverage the Tiles tag library:

    Ques: 67 What is for tag used defined by the HTML tag library?Ans:The tag is used to create a request URI based on the identical policies used with the tag but without the element. The tag has no body and supports 12attributes:

    anchor, forward, href, name, page, paramId, paramName, paramProperty, paramScope, property, scope,transaction.

    Ques: 68 What is the difference between and tag in HTML taglibrary?Ans:The tag is used to generate an HTML element to type , which representsa single option element nested inside a parent element. The tag has a body typeof JSP and supports eight attributes:value, bundle, disabled, key, locale, style, styleId, styleClass.

    The tag (as a child of the tag) is used to generate a list of HTML elements. The tag has no body and support eight attributes:

    collection, filter, labelName, lableProperty, name, property, style, styleClass.

    Ques: 69 What is the use of tag in HTML tag library used in Struts application?Ans:The tag is used to display a collection of messages stored in an ActionErrors,ActionMessages, String, or String array object. The has a body type of JSP andsupports eight attributes:id, bundle, locale, name, property, header, footer, message.

    Ques: 70 What is the use of tag in the HTML tag library?Ans:The tag is used to insert JavaScript validation methods based on the CommonsValidator Plugin. The JavaScript methods used for validation are retrieved from the validator definition file

    using the formName as the index. The tag has no body and supports eight attributes:cdata, dynamicJavaScript, formName, htmlComment, method, page, src, staticJavascript.

    Ques: 71 What is the difference between and tag in the HTML taglibrary in struts framework?Ans:The tag is used to render an HTML element with an input type of image. Theimage URL generated for this image is calculated using the value identified by the src or page attributes.You must specify one of the src or page attributes. The has a body type of JSP.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    14/26

    The tag is used to render an HTML element. The image URL generated for this imageis calculated using the value identified by the src or page attributes. You must specify one of the src orpage attributes. The has no body.

    Ques: 72 What is for tag defined in the HTML tag library in struts framework?Ans:The tag is used to render the top-level element. The tag has a bodytype of JSP and supports two attributes:* locale : If set to true, then the Locale object named by the HTTP Accept-Language header is used to

    set the language preefrences.* xhtml : If set to true, causes an xml:lang attribute to be redered as an attribute of the generated

    element.

    Ques: 73 what is the use of tag? Name all the attributes of this tag?Ans:The tag is used to create an HTML form. The form implicitly interacts with the namedActionForm bean to pre-populate the input fields values with the matching data members of the namedbean. The tag has a body type of JSP and supports 13 attributes:action, enctype, focus, focusIndex, method, onreset, onsubmit, scope, style, styleClass, styleId, target,type.

    Ques: 74 what is the use of tag? Name all the attributes of this tag?Ans:The tag is used to create an HTML element. This tag allows you to upload files that willbe populated in named ActionForm\'s identified property. The tag has a body of JSP andsupports 30 attributes:indexed, name, accessKey, alt, altKey, disabled, onblur, onchange, onclick, ondblclick, onfocus,onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover,onmouseup, property, style, styleClass, styleId, tabindex, title, titleKey, value, accept, maxlength, size.

    Ques: 75 what is for tag in the HTML tag library? Define its attributes?Ans:The tag is used to display the ActionError objects stored in an ActionErrors collection. The

    tag has a body type of JSP and support four attributes:* bundle : Specifies a MessageResources key of the resource bundle defined in the struts-config

    element.* locale : Specifies the session attribute containing the locale instance of the current. This locale is then

    used to select Locale-specific text messages.* name : Specifies the name of the request scope object that references the ActionErrors collection

    being displayed.* property : Specifies which error message should be displayed, based on each property contained in

    the ActionErrors collection.

    Ques: 76 What is for tag in HTML tag library in the Struts framework?Ans:The tag is used to render an HTML element with an input type of checkbox.

    The has a body type of JSP and supports 27 attribute:indexed, name, accessKey, alt, altKey, disabled, onblur, onchange, onclick, ondblclick, onfocus,onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover,onmouseup, property, style, styleClass, styleId, tabindex, title, titleKey, value.

    Ques: 77 What is for tag in HTML tag library in the Struts framework?Ans:The tag is used to render an HTML element with an input type of cancel. The has a body type of JSP and support the 25 attributes:

  • 8/3/2019 Struts 1.x Interview Que With Ans

    15/26

    accessKey, alt, altKey, disabled, onblur, onchange, onclick, ondblclick, onfocus, onkeydown, onkeypress,onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, property, style,styleClass, styleId, tabindex, title, titleKey, value.

    Ques: 78 How many types of tag libraries are available in the Struts framework?Ans:Five types of tag libraries are available in the Struts framework:* HTML tag library.* Tiles tag library.* Logic tag library.* Template tag library.* Bean tag library.

    Ques: 79 Describe the attributes of the tag in the HTML tag library defined in theStruts.Ans:The tag is used to render an HTML element with an input type of button. The tag has a body type of JSP and supports the following attributes:* property : Identifies the name of the input field being processed. (required)* accessKey : Identifies a keyboard character to be used to immediately move focus to the HTML

    element defined by using this tag.* alt : Defines an alternate text string for this element.* altKey : Defines a resource key (to be retrieved from a resource bundle) that references an alternate

    text string for this element.* disabled : If set to true, causes this HTML input element to be disabled. The default values is false.* indexed : If set to true, then the name of the HTML tag is rendered as propertyName[indesNumber].

    The indexed attribute is valid only when the tag is using it is nested with a tag.Other attributes are:onblur, onchange, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown,onmousemove, onmouseout, onmouseover, onmouseup, style, styleClass, styleId, tabindex, title, titleKey,value.

    Ques: 80 What is for tag in the HTML tag library defined in the Struts.

    Ans:The tag is used to insert an HTML element, including an href pointing to theabsolute location of the hosting JSP page. This tag allows you to use relative URL references, rather thana URL that is relative to the most recent requested resource. The tag has no body andsupports two attributes:* target : Represents the target attribute of the HTML tag (optional)* server : Identifies a server name to use in the href as opposed to the result of a call to

    request.getServerName() (optional)

    Ques: 81 What are the steps involved in installing the HTML tag library in your Struts application?Ans:To use HTML tag library in web application, You must complete the following steps:* Copy the TLD file packaged with this tag library struts-html.tld) to the webapps/MyAppName/WEB-INF

    directory.* Make sure that the struts.jar file is in the webapps/MyAppName/WEB-INF/lib directory.* Add the following sub-element to the web.xml file of the Web application:/WEB-INF/struts-html.tld/WEB-INF/struts-html.tld

    You must add the following taglib directive to each JSP that will leverage the HTML tag library:

  • 8/3/2019 Struts 1.x Interview Que With Ans

    16/26

    Ques: 82 How will you configure Plugins in your struts configuration file?Ans:The element is used to add Plugins to the Struts Controller. Struts Plugins are useful whenallocating resources or preparing connections to databases or even JNDI resources. The element has a single attribute, className, which is used to define the fully qualified Plugin class.Syntax:

    Ques: 83 How will you add a message Resource in your struts config file?Ans:The element is used to describe a MessageResources object for the containingapplication.Syntax:The attribute of a Element: className, factory, key, null, parameter.

    Ques: 84 What is for element used in the struts config file? Ans:The element is used to define a ControllerConfig bean(org.apache.struts.config.ControllerConfig) that represents an applicaition's runtime module configuration.

    The attributes of sub-element: bufferSize, className, contentType, inputForward, locale,maxFileSize, memFileSize, multipartClass, nocache, processorClass, tempDir.Syntax:

    Ques: 85 Describe the attributes of sub-element?Ans:The attributes of Sub-Element:* path : Represents the context-relative path of the submitted request.* type : Specifies the fully qualified class name of the Action class being described by this

    ActionMapping.* name : Identifies the name of the form bean, if any, that is coupled with Action being defined.* scope : Specifies the scope of the form bean that is bound to the desired Action. The default value is

    session.* input : Represents the context-relative path of the input form to which control should be returned if a

    validation error is encountered.* className : Specifies the fully qualified class name of the ActionMapping implementation class you

    want to use in when invoking this Action class.* forward : Represents the context-relative path of the servlet or JSP resource that will process this

    request.* include : Represents the context relative path of the servlet or JSP resource that will process this

    request. This attrubute is used if you do not want an Action to service the request to this path.

    Ques: 86 What is for sub elements in struts config file?Ans:The sub-element is used to define n-number of sub-elements. It acts as a

    container for sub-elements.The sub-element is used to describe an Action instance to the ActionServlet.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    17/26

    unknown="false"validate="true" />

    Ques: 87 What is Global forwards and define its attributes in struts config file?Ans:The sub-elementis used to define n-number of sub-elements that areavailable to any Action in the Struts Application. It acts as a container for public sub-elements.You can use sub-elements to describe a mapping of a logical name to a context relative URIpath. A forward is used to identify the target of an Action class when it returns its result.The Attributes of a sub element:* name : Contains the unique identifier identifying this target.* path : Specifies the Context relative path of the targeted resource.(required)* redirect : If set to true, causes the ActionServlet to use the HttpServletResponse.sendRedirect()

    method, as opposed to RequestDispatcher.forward() method, when sending the Action results to thetargeted resourse. The default value is false.(optional)

    Ques: 88 What are the various attributes of an sub-element in struts config file?Ans:The attribute of an sub-element:

    * bundle : A ServletContext attribute that names the resource bundle associated with theExceptionHandler handling the defined elements.* className : The fully qualified class name of the configuration bean associated with the defined

    handler.* hanler : The fully qulified class name of the ExceptionHandler that will process the contained

    sub-element.* key : Used to retrieve the message template associated with this exception.* path : The module-relative path that will act as the target of the ExceptionHandler associated with this

    exception.* scope : The scope of the ActionError object coupled with this exception.(optional)* type : The fully qualified class name of the exception defined by this sub-

    element.(required).

    Ques: 89 How you can add the Global exception in your configuration file?Ans:The sub-element is used to define n-number of sub-elements that arethrowable by any Action in a Struts application. This sub-element acts as a container for all public sub-element.The is used to associate a global exception with an ExceptionHandler.

    The following declaration in struts-config.xml:

    Ques: 90 How will you add FormBean Definitions in your struts configuration file?Ans:The sub-element is used to describe an instance of a FormBean that is later bound to anAction.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    18/26

    Ques: 91 How can you add a DataSource in your struts-config file?Ans:The first component that we configure is a DataSource.

    Ques: 92 Explain some of the Struts sub elements?Ans:The sub-elements available to the top-level Struts components are:* The Sub-Element: The sub-element contains and sub-

    elements that can be used to graphically represents its parent element in a Struts development tool.

    path to some graphics filepath to some graphics file

    * The Sub-Element: The sub-element contains a short text descriptionof its parent element for use in a Struts development tool.

    short text description of its parent element.

    * The Sub-Element: The sub-elementcontains a full length text description ofits parent element for use in a Struts development tool.

    full lenfth text description of its parent element.

    * The Sub-Element: You can use the sub element to set the value ofadditional JavaBean properties of objects describe by the sub-element's parenet.

    Ques: 93 What is Tile controllers? How will you create your own Tile Controllers?Ans:If you are putting too much java code into your Tile layout, or you have to put the same Java code into

    every Action that forwards to a page that uses a particular Tile layout, then you should use the TileController.The Controller class is similar to an Action. You can map model objects into scope so that the Tile candisplay the items. To write a Tile Controller, follow these steps:* Create a class that implements org.apache.struts.tiles.Controller.* Implement the perform method.* In the perform method, do something with the model and map the results into scope so that Tile can

    use it.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    19/26

  • 8/3/2019 Struts 1.x Interview Que With Ans

    20/26

    * Import the Tiles tag library using the taglib directive.* Ensure that the definition is created only once using the logic:notPresent tag.* Define the definition with the tiles:definition tag and pass the JSP that defines the Tile layout and the

    scope of the newly created definition.* Define the default parameters with the tiles:put tag.

    Ques: 99 How will you use the Tile layout in your struts application? Ans:To use a Tile, You need to perform the following steps:* Import the Tiles taglib with the taglib directive.* Use tiles:insert tag to insert the Tile layout into the current page.* Use tile:put tag to pass string parameters.* Use tiles:put tag to pass parameter Tiles.

    Ques: 100 How will you create a Tile layout view in your struts application?Ans:To create a TIle layout, you must do the following:* Import the Tiles taglib into the JSP by using taglib directive.* Use string parameters to display such elements as the title of the page using the tiles:getAsStringTag.* Insert the Tiles in the correct regions of the layout using the tiles:insert tag.

    * Pass any needed parameters to the internal Tiles using the sub-tag of tiles:insert called tiles:put.

    Ques: 101 What is the tiles framework in struts?Ans:The tiles framework turns the concept of jsp:includes inside out. Developers can build pages byassembling reusable Tiles. You can think of Tiles as visual components.A Tile and a Tile layout can be reused on more than one page. Tiles are other JSP pages or any webresource. Tile layouts dictate how the Tiles will be laid out on the page.

    Ques: 102 What is for tag provided by Struts specific JSP tag library.Ans:The tag is used to display the ActionError objects stored in ActionErrors collection.

    Ques: 103 What is the difference between the ActionError and ActionErrors class provided by theStruts Framework?Ans:The org.apache.struts.action.ActionError class extends the org.apache.struts.action.ActionMessage classand reresents the single error message. The key attribute of the ActionError class is used to lookup aresource from the application resource bundle, "Internationalizing your struts application".The org.apache.struts.action.ActionErrors class extends the org.apache.struts.action.ActionMessageclass and represents a collection of ActionError classes. The ActionErrors class is composed of twocontructors and a single method that allows you to add an ActionError object to the current collection ofActionErrors.

    Ques: 104 Give name of the error management classes provided by the Struts framework?Ans:

    The Struts framework provides two error management classes:* ActionError* ActionErrors

    Ques: 105 What are the two i18n components of a Struts Application?Ans:The tow main components packaged with the Struts framework for internationalization of your Strutsapplication are:* Message class that references a resource bundle containing Locale-dependent string and managed by

    the application Contorller.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    21/26

    * JSP custom tag, , which is used in the view layer to present the actual stringmanaged by the Contorller.

    Ques: 106 What are the extensions of the ActionMapping provided by the struts?Ans:The struts framework provides two extended ActionMapping classes:

    * org.apache.struts.action.SessionActionMapping* org.apache.struts.action.RequestActionMapping.

    Ques: 107 How will you create your own ActionMapping?Ans:To create your own ActionMapping extention, you have to perform the following steps:* Create a class that extends the org.apache.struts.action.ActionMapping class.* Define the additional properties that will be used to describe your Action objects.* Call the super() method, which calls the ActionMapping's default constructor at the beginning of your

    action mapping's contructor.* Define matching setters and getters that can be used to modify and retrieve the values of the defined

    properties.

    Ques: 108 What is an ActionMapping?

    Ans:An ActionMapping object describes an Action instance to the ActionServlet. It represents the informationthat uniquely defines an instance of a particular action class. The values defined by an ActionMappingobject are what make a particular definition unique.The ActionMapping object also provides useful information to the Action.execute() method, giving anAction object the ability to alter its behaviour based on the values describing a particular ActionMappinginstance. The signature of the Action.execute() method:

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,HttpServletResponse response){//some code here}

    Ques: 109 What is the alternatice approach to the ActionForm in Struts? Ans:

    You have to develop a new ActionForm object for just about every piece of business logic, i.e. for everyAction object. This process is time consuming and irritating.Struts solve this problem by introducing of a dynamic ActionForm, called the DynaActionForm. It gives thedeveloper the ability to define a Form object using an XML entry in the struts-config.xml file.

    Ques: 110 What are the ActionForm Bean objects in Struts?Ans:The org.apache.struts.action.ActionForm objects are JavaBeans that are used to encapsulate andvalidate the request data submitted by an HTTP request. All of the ActionForm must extends theorg.apache.struts.action.ActionForm.It contains setters and getters methods. The setters method are called by The Struts framework when arequest is submitted with a parameter matching a data member's name.

    Ques: 111 What are the two input tags of the tags?Ans:The tag serves as the container for all other Struts HTML input tags. It acts as a parent totwo other HTML tags:

    The tag:This tag is equivalent to the HTML text input tag, with the only difference being the property attribute,which names a unique data member found in the ActionForm bean class named by the form's typeattribute.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    22/26

    The tag:This tag simply emulates an HTML Submit button by submitting the request to the targeted action.

    Ques: 112 Which class would you use to forward the group related actions and what are stepsinvolved.Ans:The DispatchAction class is used to forward the group related actions into one class. DispatchAction is anabstract class, so you must override it to use it. It extends the Action class.Rather than having a single execute method, you have a method for each logical action. TheDispatchAction dispatches to one of the logical actions represented by the method. It picks a method toinvoke based on an incoming request parameter. You should follow the following steps:* Create an action handler class that subclasses DispatchAction.* Create a method to represent each logical related action.* Create an action mapping for this action handler using the parameter attribute to specify the request

    parameter that carries the name of the method you want ot invoke.* Pass the action a request parameter that refers to the method you want to invoke.

    Ques: 113 What is the difference between the ForwardAction and the IncludeAction in the Struts?Ans:

    The main difference between the ForwardAction and the IncludeAction is that you need to useIncludeAction only if the action is going to be included by another action or JSP.Therefore, if you have code in your JSP that looks like this:

    the action could not use a ForwardAction because it would forward control to the new action rather thanincluding its output within the output of the JSP, or throw a Ill igalStateException if the output buffer isalready committed.

    Ques: 114 Which is better approach, forward attribute or ForwardAction in the Struts framework toforward the request to next view.?Ans:The Struts configuration file includes support for both the forward attribute and ForwardAction.

    The ForwardAction:

    The forward attribute:

    These two mappings are funtionally equivalent. It is an easy decision to pick the one you should use, ofcourse, the shorter one.

    Ques: 115 What are the advanced Action classes? Why do you need ForwardAction class?Ans:Advanced Action classes are the built-in Action classes that come with the Struts. These are:* ForwardAction

    * IncludeAction* DispatchAction* LookupDispatchAction* SwitchAction

    ForwardAction: The ForwardAction acts as a bridge from the current view (JSP) and the pages it links to.It uses the RequestDispatcher to forward to a specified web resource. It is the glue that allows you to linkto an action instead of directly to a JSP. It follow the two steps:* Use the tag with the action attribute, add a link to a JSP page that points to the action.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    23/26

    * Create an action mapping in the Struts configuration file that uses ForwardAction with the parameterattribute to specify the JSP path.

    Ques: 116 How will you configure the Plugin in your web application.Ans:To deploy and configure your Plugin class, you must:* Compile and move the Plugin class file into your application's WEB-INF/classes/ directory.* Add a element to your struts-config.xml file. For example:The element should be the last element in the struts-config.xml file.

    * Restart the Web application.

    Ques: 117 What is RequestProcessor? How will you create your own RequestProcessor?Ans:The RequestProcessor is the class that you need to override when you want to customize the processingof the ActionServlet. It contains a predefined entry point that is invoked by the Struts controller with eachrequest. The entry point is the processPreprocess() method.Steps involved in creation your own RequestProcessor:* Create a class that extends the org.apache.struts.action.RequestProcessor class.* Add a default empty constructor to the RequestProcessor implementation.

    * Implement your processPreprocess() method.

    Ques: 118 What are the steps involved in Struts Plugins?Ans:All Plugins must implement the two Plugin methods init() and destroy(). To develop your own Plugin Youmust complete the following steps:* Create a class that implements the org.apache.struts.action.Plugin interface.* Add a default empty contructor to the Plugin implementation. You must have a default constructor to

    ensure that the ActionServlet property creates your Plugin.* Implement both the init() and destroy() methods and your implementation.* Compare the new Plugin and move it into the web applocation's classpath.* Add a element to the application's struts-config.xml file describing the new Plugin.

    Ques: 119 What are Struts Plugins?Ans:Struts Plugins are modular extensions to the Struts COntroller. They are defined by theorg.apache.struts.action.Plugin interface. Struts Plugins are useful are useful when you are allocatingresources or preparing connections to the databases or even JNDI resources.This interface defines two lifecycle mathods: init() and desstroy().

    Ques: 120 Describe the purpose of the Action class?Ans:The org.apache.struts.action.Action class is a most common component of the Struts Controller. Thisclass must be extended for each specialized Struts function in your application. The collection of theseAction classes is what defines your web application.To develop your own Action class, you must complete the following steps:

    * Create a class that extends the org.apache.struts.action.Action class.* Implement the appropriate execute() method and add your specific business logic.* Compile the new Action and move it to the Web application's classpath, i.e. /WEB-INF/classes

    directory.* Add an element to the application's struts-config.xml file describing the new Action.

    Ques: 121 What is for Action.execute() method?Ans:The execute method is where your application logic begins. It is the method that you need to overridewhen defining your own Actions. The execute() method has two functions:

  • 8/3/2019 Struts 1.x Interview Que With Ans

    24/26

    * It performs the user-defined business logic associated with your application.* It tells the Framework where it should next route the request.

    The Struts framework defines two execute() methods. The first execute() implementation is used whenyou are defining custom Actions that are not HTTP specific, i.e. anlogous to the

    javax.servlet.GenericServlet class. The second, HTTP specific, You need to override the Action.execute()method and is anlogous to the javax.servlet.HttpServlet class.Its signature is:

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,HttpResponse response) throws IOException, ServletException{// some code here}

    Ques: 122 Who calls the ActionForm.validate() method inside the ActionServlet.Ans:The RequestProcessor.process() method calls the ActionForm.validate() method, which checks thevalidity of the of the submitted values.

    Ques: 123 What is the process() method doing in the ActionServlet class?Ans:The process() method gets the current RequestProcessor and invokes the RequestProcessor.process()

    method.The RequestProcessor.process() method is where the current request is actually serviced. Thismethod retrieves from the struts-config.xml file, the element that matches the path submitted onthe request. It does this by matching the path passed in the tag's action element to the element with the same path value.

    Ques: 124 What is the entry point to ActionServlet when a request comes in. Ans:The two main entry point into the ActionServlet are the same as any other servelt : doGet() and doPost().They call single method named process(). The struts specific behaviour begin with this mehtod.

    Ques: 125 What is ActionServlet class in the struts controller?Ans:The org.apache.struts.action.ActionServlet is the backbone of all Struts application. It is the main

    controller component that handles the client request and determines whichorg.apache.struts.action.Action will process each received request. It serves as an Action factory -creating specific Action classes based on the user's request.

    Ques: 126 What are the various struts controller components?Ans:Four distinct Struts Controller components:* The ActionServlet class* The Action class* Plugins* RequestProcesser

    Ques: 127 How will you tell the web application and container about your ActionServlet?

    Ans:This can be accomplished by adding the following servlet definition to the web.xml file :

    actionorg.apache.struts.action.ActionServletconfig/WEB-INF/struts-config.xml

  • 8/3/2019 Struts 1.x Interview Que With Ans

    25/26

    1

    Once you told the container about the ActionServlet you need to tell it when it should be executed byadding element in web.xml file :

    action*.do

    This mapping tells the web application that whenever a request is received with .do appended to the URLthen the servlet named action should service the request.

    Ques: 128 Which mathod is use to forward the result to the appropriate view in the Action class inStruts?Ans:The findForward() method is use to forward the result to the appropriate view in the Action class. Thismethod takes the paremeter name for the view file to which the result is being forwarded.

    Ans:ActionMapping Class's findForward(String) method...in ActionClass ActionMapping is Passed as Parameter so we do not need to create Seprate instance forthat ......

    Ques: 129 What are the parameters used in the Action.execute() method in the Struts.Ans:The following parameters are used in the Action.execute(...) method :* ActionMapping : The ActionMapping class contains all of the deployment information for a particular

    Action object. This class is used to determine where the result of the class (that extends the Action class)will be sent once its processing is complete.* ActionForm : Represents the form inputs cntaining the request parameters from the view referencing

    this Action bean.

    * HttpServletRequest : Reference to the current Http request object.* HttpServletResponse : Reference to the current Http response object.

    Ques: 130 What is ActionForm in the struts?Ans:When an is submitted, the Struts framework populates the matching data members of theActionForm with the values entered in the tag. The Struts framework does this by usingJavaBean introspection. This is all done by the class specified in the type attribute of the tag. This class will extends the org.apache.struts.action.ActionForm, as must all ActionForm objects witha get and set accessor that match its data members.

    Ques: 131 Describe the struts specific form tag?Ans:

    Instead of using the standard HTML Form tag, like most HTML pages, the struts specific Form tag is :

    ..........

    This tag with its subordinate input tags, encapsulates Struts form processing. The Form tag attributes are:* action : Represents the URL to which this form will be submitted. This is also used to find the

    appropriate ActionMapping in the Struts configuration file.

  • 8/3/2019 Struts 1.x Interview Que With Ans

    26/26

    * name : Identifies the key that is used to lookup the appropriate ActionForm that will represent thesubmitted form data.* type : Names the fully qualified classname of the form bean you want to use in this request.

    To use the struts specific tag you have to use the taglib directive:

    Ques: 132 How will you install struts framework in your web application?Ans:The follwing steps are involved to install struts framework in your web application :

    * Uncompress the Struts Archive to your local disk.* Create a new web Application say, MyStrutsApp inside the webapps directory under the tomcat

    directory.* Copy all the jar files, extracted from the lib directory into the /webapps/MyStrutsApp/WEB-INF/lib

    directory.* Create an empty web.xml file and copy it to the /webapps/MyStrutsApp/WEB-INF/ directory.* Create an empty struts-config.xml file and copy it to the /webapps/MyStrutsApp/WEB-INF/ directory.

    The struts-config.xml file is the diployment descriptor for all Struts applicattion. It is the file that glues all ofthe MVCcomponents together.

    Ques: 133 What is MVC design pattern?Ans:MVC stands for Model-View-Controller. The MVC design pattern is originated from Smalltalk, consists ofthree components : a Model, a View, and a Controller.

    MODEL : Represents the data objects. The Model is what is being manipulated and persented to theuser. Model contains the business logic of the application.

    VIEW : Serves as screen representation of the Model. It is the object that represents the current state ofthe objects.

    CONTROLLER : Defines the way the user interface reacts to the user's input. The Controller component

    is the object that manipulates the Model, or data object.

    Ques: 134 What are the various steps involved in the implementaion of struts?Ans:The struts framwork models its server side implementation of the MVC using a combination of JSPs,custom JSP tags, and a Java Servlet. It involves the following steps :

    * The incoming request is received by the ActionServlet, which acts as the controller, and theActionServlet looks up the requested URI in an XML file.* The ActionClass performs its logic on the Model components associated with the application.* Once the Action has completed its processing, it returns control to the ActionServlet with a key that

    indicates the result of its processing. ActionServlet uses this key to determine where this result should beforwarded for presentation.

    * The request is complete when the ActionServlet response by forwarding the request ot the view thatwas linked to the returned key, and this view presents the result of the Action.

    Ques: 135 What is struts?Ans:The Jakarta struts project, an open source project supported by the Apache software Foundation, is aserver side java implementation of the modetl view controller (MVC) design pattern.The struts framework designed to create Web application that easily separate the presentation layer andallow it to be abstracted from the transaction and data layers.