Ads 468x60px

Pages

Wednesday, 4 July 2012

struts interview questions


Ques: 51 Describe the attributes of <action> sub-element?
Ans: The attributes of <action> 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: 52 What is for <controller> element used in the struts config file?
Ans: The <controller> element is used to define a ControllerConfig bean (org.apache.struts.config.ControllerConfig) that represents an applicaition's runtime module configuration.
The attributes of <controller> sub-element: bufferSize, className, contentType, inputForward, locale, maxFileSize, memFileSize, multipartClass, nocache, processorClass, tempDir.
Syntax:
<controller processorClass="MyRequestProcessor" nocache="true" />

Ques: 53 How will you add a message Resource in your struts config file?
Ans: The <message-resources> element is used to describe a MessageResources object for the containing application.
Syntax:
<message-resources parameter="configuration parameter" key="main" />
The attribute of a <message-resources> Element: className, factory, key, null, parameter.

Ques: 54 How will you configure Plugins in your struts configuration file?
Ans: The <plug-in> element is used to add Plugins to the Struts Controller. Struts Plugins are useful when allocating resources or preparing connections to databases or even JNDI resources. The <plug-in> element has a single attribute, className, which is used to define the fully qualified Plugin class.
Syntax:
<plug-in className="Fully qualified plugin class name" />

Ques: 55 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 <taglib> sub-element to the web.xml file of the Web application:
  <taglib>
    <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  </taglib>

You must add the following taglib directive to each JSP that will leverage the HTML tag library:
  <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

Ques: 56 What is for <html:base/> tag in the HTML tag library defined in the Struts.
Ans: The <html:base/> tag is used to insert an HTML <base> element, including an href pointing to the absolute location of the hosting JSP page. This tag allows you to use relative URL references, rather than a URL that is relative to the most recent requested resource. The <html:base/> tag has no body and supports two attributes:
  * target : Represents the target attribute of the HTML <base> 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: 57 Describe the attributes of the <html:button/> tag in the HTML tag library defined in the Struts.
Ans: The <html:button/> tag is used to render an HTML <input> element with an input type of button. The <html:button/> 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 <logic:itereate/> tag.
Other attributes are:
onblur, onchange, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, style, styleClass, styleId, tabindex, title, titleKey, value.

0 comments:

Post a Comment