Search

Complete reference to struts frame work interview questions basic to advanced level : SE to Team Lead level Part - 9

Latest Answer: Hi to allAs Madhav specified  (Struts follows MVC architecture and has many design patterns which it uses inside(ex Frontcontroller,Value Objects). )what are the other design patterns which it uses inside and can it be brief ...

Latest Answer: Static methods are BAD BAD thing, should b always prohibited. They bind u to a concrete class. Remeber the first good practice of OOP, always program to interfaces rather than classes. Use a factory with singelton rather than a static method. However ...
Read Answers (4) | Asked by : samidurai.v

Latest Answer: Apache struts and Jakarta Struts are one or the same thingbyee ...
Read Answers (4) | Asked by : Developer

I have linux OS.I installed Tomcat 4. in Linux.Now, i have to deploy My web application into that using WAR file.Please tell me steps....and also steps for the creating the WAR file too.
Read Answers (4) | Asked by : Rahul Bandgar

Wats meant by struts?how to use struts in IBM websphere appli. ?and how to managed with struts?(plz answer simply just an intro. don\'t go very deep)
Read Answers (3) | Asked by : karthik

Latest Answer: Servlet Config parameters are set for the servlet initialization, these information is necessary for the servlet startup, eg.: Database connectivity, other xml files. etc.Servlet Context are used by the servlets to interact with the SERVER, servlet can ...
Read Answers (6) | Asked by : p.vinodReddy

Latest Answer: Good Explanation !! keep it  up !! ...
Read Answers (4) | Asked by : Sonu

Latest Answer: The findByPrimaryKey() method works like the read() method, except that the findByPrimaryKey() method retrieves a single TxObject directly from the database using a primary key without going through a TxCursor. The primary key can be any primary key. ...
Read Answers (1) | Asked by : Hari Krishna P

please post the answer 
Latest Answer: Struts controller uses the command design pattern and the action classes use the adapter design pattern. The process() method of the RequestProcessor uses the template method design pattern. Struts also implement the following J2EE design patterns. ...
Read Answers (26) | Asked by : sudhakar

Latest Answer: MVC1A Model 1 application control is decentralized, because the current page being displayed determines the next page to display. In addition, each JSP page or servlet processes its own inputs (parameters from GET or POST). In some Model 1 architectures, ...
Read Answers (20) | Asked by : Chennaiah

pl any one answer 
Latest Answer:               To pass the values from dyna form to entity bean,   we should follow some design patterns.from action to business delegate(java bean)----->sesstion bean1----->>sesstion ...
Read Answers (3) | Asked by : vishnu

need answer 
Latest Answer: Struts implements MVC design so that we can divide the web application in to view, data access/modify and controller layers.  JSPs and HTMLs are come into view, when a user enters data into form and submits a request, it goes to Action servlet, in which ...
Read Answers (4) | Asked by : saraswati

Latest Answer: When we want the action form to persist the values across the request, we set the action form to session scope.For ex. When i submit the registration form with some errors in the form, then in the Action form fields validation throws errors in the JSP ...
Read Answers (13) | Asked by : kanthakumar

Yes, other than JSP we can use Swing, JSF, Cocoon etc as a front end for our struts application. Here is a link to the article for using struts with swing as front end 
Latest Answer: But how can I use the Swing, or any other technology for front end view? ...
Read Answers (10) | Asked by : Amit Mudgal

No, These features are turned off by default. One has to enable the plugins by properly inserting entries in Struts-config.xml 
Latest Answer: Ya, All about sturts is framework. It will provide some custom tag libraries. Also struts give one validator frame work for both client and server validation. We can make use of this validator framework so that it will reduce the effort of devloper to ...
Read Answers (4) | Asked by : Amit Mudgal

Latest Answer: no it is not possible ...
Read Answers (1) | Asked by : shailendra

Is there any way to put my custom name to LIB folder which i am going to place in WEB-INF folder of struts application?
please answer this question 
Read Answers (5) | Asked by : gskumar

Latest Answer: Due its a bad practice to instantiate form beans in your code as their life cycle is managed by STRUTS in a kinda IOC style ...

Answered by asreeni on 2005-04-08 03:24:40: The core of the Struts framework is a flexible control layer based on standard technologies like Java Servlets, JavaBeans, ResourceBundles, and XML, as well 
Latest Answer: I worked with struts it completely MVC base. I used SHINE pattern. It is a MVC base too. Actually it is an open source project to implement J2EE application. ...

Latest Answer: Struts flow After developing the struts application after deploying it is the server & when you started the server then following things will happened Container initializes the web.xml When container reading the data from web.xml container checks ...

Latest Answer: ActionForm is static form bean and DynaActionForm is dynamic formbean. If we want to use DynaActionForm no need write formbean we need to write all the jsp fields in Sturts-config.xml  ...

Latest Answer: Struts Framework developed using MVC design pattern. It will represent Controller and view layer.In view layer it will use taylibraries and jsp, jstl tags, htmlIn controller layer ActionServlet act as a controller layer ...

1. Action Servlet2. Action Classes3. Action Form4. Validator Framework5. Message Resources6. Struts Configuration XML Files7. View components like JSP 
Latest Answer: 1. Action Servlet2. Action Classes3. Action Form4. Validator Framework5. Message Resources6. Struts Configuration XML Files7. View components like JSP8. Struts-tag laibraries  ...

Latest Answer: Please give me code for this :In single JSP how we maintain only one Basically Dispatch action is used when you have multiple submit buttons in a single form.The Dispatch action is a class which extends the Struts DispatchAction , and encapsulates all ...

Latest Answer: There are only five struts tag libraries1)Bean tag lib2)Html tag lib3)logic tag lib4)nested tag lib5)Template tag libothers are JSTL tag libraries(ex: c.tld,sql.tld,fmt.tld) ...

Latest Answer: In tiles-def.xml we can define the definations which specifies the different components to plugin to generate output.resourcebundle.properties maintains messages used in the struts project.validation.xml maintains the validation code for validating form ...

Latest Answer: The new features added to Struts 1.1 are 1. RequestProcessor class 2. Method perform() replaced by execute() in Struts base Action Class3. Changes to web.xml and struts-config.xml4.Declarative exception handling5.Dynamic ActionForms6.Plug-ins7.Multiple ...

Latest Answer: Yes, we use Service locator design pattern    We can call from Action Calss through JNDI to home object.          then call remote object from home object ...

Latest Answer: hi,to handle the errors:in struts project to handle the error objet by using ActionError object and to handle the errors by using ActionErrors object.for supposeActionError ae1=new ActionError("err.one");ActionError ae2=new ActionError("err.two");Action ...

Latest Answer: The core class of struts framework is 1) ActionServlet2) Action3) ActionForward4) ActionMapping5) ActionErrors6) RequestProcessor7) ActionForm ...

Latest Answer: Action Class acts as a controller b/n user data and business logic.It is having execte() method using this we are calling business logic.Execute method syntax :-public ActionForward execute(ActionMapping am,ActionForm fm,HttpservletRequest rq,HttpServletResponse ...

Latest Answer: Tokens are used to prevent multi click problem in struts. In Action class method at the begining of the code, need to call the saveToken() that generates an unique identifier for the "request url" and stotes it in the session and also in the ...

Latest Answer: These are the tags we can define ,,,,,  ...

Latest Answer: Action Errors(org.apache.struts.action.ActionErrors): A class that encapsulates the error messages being reported by the validate() method of an ActionForm. Validation errors are either global to the entire ActionForm bean they are associated with, or ...


Q: how to perform data validation in a struts application?
-to transfer complete and proper input to the model layer and there by to the database, server side validations are performed on form data.
-server side validation can be implemented in two ways.
1.programmatical  2.declarative
Q: what is programmatical validation and how to implement it?
-if validation code is explicitly developed by the struts application developer with in the validate method of the form-bean, it is known as programmatical validation.
-steps to perform programmatical validation:
1. in the form bean override validate method and implement validation code.
2. enable the validation check by making an entry in struts-config.xml
<action ………… validate=”true” input=”/some.jsp”/>
-if validation fails, control switched to some.jsp.
3.developing and configuring the resource bundle with error keys and corresponding error messages.
4.using <html:errors /> in the input page to display error messages.
Ex: public class LoginForm extends ActionForm{
private string username;
private String password;
setters&getters
public ActionErrors validate(ActionMapping am,HttpServletRequest req) {
ActionErrors ae=new ActionErrors();
If(username.equals(“  “)||username==null)
ae.add(“username”, new ActionError(“error.name.required”));
if(password.equals(“  “)||password==null)
ae.add(“password”, new ActionError(“error.password.required”));
return ae;
}
}
-if ActionErrors returned by validate method is empty or null then RequestProcessor understands that the form data is valid. If not RequestProcessor considers the form data is valid.
Q: what is ActionError?
-ActionError is struts library class whose instance represents validation failure of one data field.
-ActionError instance takes resource bundle key from its constructor.
-validate method of form bean creates ActionError instance for each validation failure of a form field and adds to ActionErrors object.
Q: what is ActionErrors ?
-it is a collection class from struts library.
-this object holds the references to ActionError objects.
-struts framework known about validation failure depending upon this object.
-if ActionErrors returned by the validation method empty or null then RequestProcessor understands that the  form data is valid. If not RequestProcessor considers the form data is not valid.
Q: what is declarative validation? How to implement it?
-instead of struts developer writing validation code explicitly using framework given validation functionality in a struts application by specifying the validation requirements in a special xml file is known as declarative validation.
-steps to implement declarative validation:
1.developing validation.xml file which indicates to the framework our validation needs.
2.framework provided validator-rules.xml and our own developed validation.xml have to be placed in WEB-INF.
3.configure ValidatorPlugIn in struts-config.xml file so that it loads the xml file definitions into struts environment.
4.develop the form bean class that extends validatorForm.
<plug-in className=”org.apache.struts.validator.ValidatorPlugIn”>
<set-property property=”pathnames” value=”/WEB-INF/validation.xml,/WEB-INF/validator-rules.xml”/>
</plug-in>
Q: what is validator-rules.xml?
 -validator-rules.xml is given by struts framework.
-this file is a collection of validators(tags).
-each validator tag specifies a logical name to built-in validation method. It also specifies the error key that is returned by the java validation method.
-in this file, for each validation java method a javascript function also specified which is useful for client side validations.
-this file specifies all the possible built-in validation routines given by struts framework.
Q: what is validation.xml files?
-it specifies to the framework which routines are required for which form beans of the application
-<form-validation>
<formset>
<form name=”loginform”>
<field property=”username” depends=”required”>
<arg0 key=”username”/>
</field>
<field property=”password” depends=”required,minlength”>
<arg0 key=”password”/>
<arg1 key=”4” resource=”false” />
<var>
<var-name>minlength</var-name>
<var-value>4</var-value>
</var>
</field>
</form>
</formset>
</form-validation>
Q: what is mean by depends=”mask”?
-mask is the predefined validator rule which allows the programmer to add user defined logic in the  form of regular expression.
-the error message related to this rule can be defined by the programmer manually in properties file.
Ex: <var>
<var-name> mask</var-name>
<var-value>[a-z A-Z] *$</var-value>
</var>
<field property=”pwd” depends=”required,mask”>
<arg0 key=”my.pass”/>
<msg name=”mask” key=”my.mask.msg”/>
-<msg> tag is used for defining message related to the mask rules.
Q: what are the different types of built-in actions in struts?
1.ForwardAction
2.IncludeAction
3.DispatchAction
4.LookupDispatchAction
5.MappingDispatchAction
6.LocaleAction
7.SwitchAction
-the above all the classes are from org.apache.struts.actions package.
Q: what is the difference between Action and DispatchAction?
-in Action class, we develop our own application specific application logic in execute() method only.
-in DispatchAction, we develop our own application specific application logic in our own defined methods which prototype is same as execute method.
-in DispatchAction, don’t override the execute() method .
-if we want to perform multiple functionalities to be performed by the action required from the same form based on the given parameter value.
Ex:  public class MyAction extends DispatchAction{
Public ActionForward sub/add(ActionMapping am,ActionForm af,HttpServletRequest req,HttpServletResponse res) {
----- --
}
}
-configure the above action class with a special attribute parameter in addition to other attributes. This attribute value must match the request parameter name from the web form.
<action path=”/myaction” type=”MyAction” parameter=”submit”>
Q: how to enable client side validation provided by validator framework?
-in the input page make use of javascript tag of html library
<html:javascript  formName=”loginform” />
-once the above tag is executed, a javascript function with name validateLoginform() is generated with client side validation code appended to the html page generated by input jsp.
-in the input page, make use of “onSubmit” attribute of form tag of html library.
<html:form …..     onsubmit=return validateLoginform(this)”>
-when ever end-user clicked on the submit button of the html form, “onSubmit” event is fired and the specified javascript function is called in which, client side validation code is implemented. This method returns false if validation is failed . then the form is not submitted to the server.


No comments:

Post a Comment