Top X Struts Interview Interrogation Together With Answer - J2ee
Top X Struts Interview Interrogation Together With Answer - J2ee - Hallo sahabat BEST LEARNING JAVA, Pada Artikel yang anda baca kali ini dengan judul Top X Struts Interview Interrogation Together With Answer - J2ee, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan
Artikel core java interview question,
Artikel J2EE,
Artikel struts, yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.
Judul : Top X Struts Interview Interrogation Together With Answer - J2ee
link : Top X Struts Interview Interrogation Together With Answer - J2ee
public shape ConvertCurrencyAction extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
DynaActionForm currencyConverterForm = (DynaActionForm)form;
// past times this way nosotros tin cry back the value which is laid inwards the JSP Page
String fromCurrency = (String) currencyConverterForm.get("fromCurrency ");
String toCurrency = (String) currencyConverterForm.get("toCurrency ");
return mapping.findForward("success");
}
}
}
In the JSP page
<html:text property=" fromCurrency " size="30" maxlength="30"/>
<html:text property=" toCurrency " size="30" maxlength="30"/>
Further Learning
Java Web Fundamentals By Kevin Jones
Struts 2 Framework for Beginners
Spring Framework Master Class - Beginner to Expert
Anda sekarang membaca artikel Top X Struts Interview Interrogation Together With Answer - J2ee dengan alamat link https://bestlearningjava.blogspot.com/2019/09/top-x-struts-interview-interrogation.html
Judul : Top X Struts Interview Interrogation Together With Answer - J2ee
link : Top X Struts Interview Interrogation Together With Answer - J2ee
Top X Struts Interview Interrogation Together With Answer - J2ee
This fourth dimension its Struts interview questions, After writing Spring interview questions few weeks dorsum I was thinking what to selection for my interview serial in addition to and so I idea most whatever spider web framework, in addition to on that struts is my favorite. Struts are opened upward source framework used for spider web application. These Struts interview questions are based on my sense equally good equally collected past times friends in addition to colleague in addition to they are non alone skilful for interview exercise but too shows a novel administration of learning for anyone who is non real familiar amongst struts. The best way to utilization these interview questions does revise earlier going for whatever Struts interview or whatever Java or J2EE interview. I accept too provided answers to these struts interview questions but you lot tin too enquiry to a greater extent than on Google but these answers of struts are sufficient on interview perspective.
Struts Interview Questions Answer
Question 1: What is Struts? Why you lot accept used struts inwards your application or project.
Ans: This is the rootage interview questions anyone asks inwards Struts to acquire the interview rolling. Most ordinarily asked during the less senior level. Struts are zippo but opened upward source framework generally used for making spider web application whenever nosotros utilization the term framework way it comprises JSP, servlet, custom tags message resources all inwards i parcel which makes developer chore real easy. Its is based on MVC pattern which is model sentiment Controller pattern.
Now why nosotros utilization Struts? So principal argue is if nosotros become amongst servlet all HTML code which is related to pattern component generally volition come upward within coffee code which makes code unmaintainable in addition to complex similarly if utilization JSP, all coffee code related to draw of piece of occupation concern come upward within pattern component which i time again brand code complex, that’s why MVC pattern come upward into existence in addition to which split upward the business, pattern in addition to controller in addition to struts were made based on this pattern in addition to tardily to prepare spider web application.
The keyword to reply this Struts interview questions is MVC pattern pattern, Front Controller Pattern in addition to meliorate menses administration which generally interviewer are looking to hear. You tin read to a greater extent than pattern pattern interview enquiry on my post 10 Interview enquiry on Singleton Pattern inwards Java
The keyword to reply this Struts interview questions is MVC pattern pattern, Front Controller Pattern in addition to meliorate menses administration which generally interviewer are looking to hear. You tin read to a greater extent than pattern pattern interview enquiry on my post 10 Interview enquiry on Singleton Pattern inwards Java
Question 2: What are the principal classes which are used inwards struts application?
Ans 2: This is around other beginner’s marker Struts interview question which is used to banking company check how familiar candidate is amongst Struts framework in addition to API. Main classes inwards Struts Framework are:
Action servlet: it’s a backbone of spider web application it’s a controller shape responsible for treatment the entire request.
Action class: using Action classes all the draw of piece of occupation concern logic is developed us telephone telephone model of the application also.
Action Form: it’s a coffee edible bean which represents our forms in addition to associated amongst activity mapping. And it too maintains the session nation its object is automatically populated on the server side amongst information entered from a shape on the customer side.
Action Mapping: using this shape nosotros do the mapping betwixt object in addition to Action.
ActionForward: this shape inwards Struts is used to frontwards the termination from controller to destination.
Question 3: How exceptions are handled inwards Struts application?
Ans: This is picayune tough Struts interview question though looks quite basic non every candidate knows most it. Below is my reply of this interview questions on Struts:
There are 2 ways of treatment exception inwards Struts:
Programmatically handling: using travail {} grab block inwards code where an exception tin come upward in addition to menses of code is too decided past times programmer .its a normal coffee linguistic communication concept.
Declarative handling: There are 2 ways i time again either nosotros define <global-Exception> tag within struts-config.XML file
<exception
key="stockdataBase.error.invalidCurrencyType"
path="/AvailbleCurrency.jsp"
type="Stock.account.illegalCurrencyTypeException">
key="stockdataBase.error.invalidCurrencyType"
path="/AvailbleCurrency.jsp"
type="Stock.account.illegalCurrencyTypeException">
</exception>
The programmatic in addition to Declarative way is sometimes too asked equally follow-up questions are given candidate’s response on cognition on Struts.
Key: The key represents the key acquaint inwards MessageResource.properties file to depict the exception.
Type: The shape of the exception occurred.
Path: The page where the controls are to live followed is representative exception occurred.
See Struts inwards Action for to a greater extent than details:
Path: The page where the controls are to live followed is representative exception occurred.
See Struts inwards Action for to a greater extent than details:
Question 4: How validation is performed inwards struts application?
Ans: Another classic Struts interview enquiry it’s higher on a marker than previous interview questions because it’s related to of import validation concept on a spider web application. In struts validation is performed using validator framework, Validator Framework inwards Struts consist of 2 XML configuration files.
1. validator-rules.xml file: which contains the default struts pluggable validator definitions. You tin add together novel validation rules past times adding an entry inwards this file. This was the master copy beauty of struts which makes it highly configurable.
2. Validation.xml files which incorporate details regarding the validation routines that are applied to the dissimilar Form Beans.
These 2 configuration files inwards Struts should live placed somewhere within the /WEB-INF folder of the application to pop off on it prophylactic from the customer in addition to arrive available inwards Classpath.
<!-- Validator plugin -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
Now the adjacent measuring towards validation is created mistake messages within the message resources belongings file which are used past times validator framework.
Message resources Contain:
1. CurrencyConverterForm.fromCurrency = From Currency
2. CurrencyConverterForm.toCurrency=To currency
3. errors.required={0} is required.
Then validation rules are defined inwards validation.xml for the fields of shape on which nosotros wish want validation
Form edible bean code that extend DynaValidatorForm
Eg; <form-beans>
<form-bean name="CurrencyConverterForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="fromCurrency" type="java.lang.double" />
<form-property name="toCurrecny" type="java.lang.double" />
</form-bean>
</form-beans>
Validation.xml file contains
<form-validation>
<formset>
<form name=" CurrencyConverterForm ">
<field property=" fromCurrency " depends="required">
<arg key=" CurrencyConverterForm. fromCurrency "/>
</field>
<field property=" toCurrecny " depends="required ">
<arg key=" CurrencyConverterForm.toCurrency "/>
</field>
</form>
</formset>
</form-validation>
To associate to a greater extent than than i validation dominion to the belongings nosotros tin specify a comma-delimited listing of values. The rootage dominion inwards the listing volition live checked rootage in addition to and so the adjacent dominion in addition to so on. Answer of this Struts questions gets chip longer but it’s of import to impact these of import concepts to arrive useful.
Question 5: What is the Difference betwixt DispatchAction in addition to LookupDispatchAction inwards Struts Framework?
This Struts interview enquiry is pretty guide frontwards in addition to I accept seat the differences inwards tabular format to arrive tardily to read.
Dispatch Action | LookupDispatchAction |
It’s a nurture shape of LookupDispatchAction | Subclass of Dispatch Action |
DispatchAction provides a machinery for grouping a laid of related functions into a unmarried action, hence eliminating the demand to create split upward actions for each function. | An abstract Action that dispatches to the subclass mapped executes method. This is useful inwards cases where an HTML shape has multiple submit buttons amongst the same name. The push cite is specified past times the parameter belongings of the corresponding ActionMapping. |
If non using Internalization functionality in addition to so dispatch activity is to a greater extent than useful. | Lookup Dispatch Action is useful when nosotros are using Internalization functionality |
DispatchAction selects the method to execute depending on the asking parameter value which is configured inwards the XML file. | LookupDispatchAction looks into the resources parcel file in addition to finds out the corresponding key name. We tin map this key cite to a method cite past times overriding the getKeyMethodMap() method. |
DispatchAction is non useful for I18N | LookupDispatchAction is used for I18N |
Question 6: How you lot tin cry back the value which is laid inwards the JSP Page inwards the representative of DynaActionForm?
Ans: DynaActionForm is a pop theme inwards Struts interview questions. DynaActionForm is a subclass of ActionForm that allows the creation of shape beans amongst dynamic sets of properties, without requiring the developer to create a Java shape for each type of shape bean. DynaActionForm eliminates the demand of FormBean shape in addition to straight off the shape edible bean definition tin live written into the struts-config.XML file. So, it makes the FormBean declarative in addition to this helps the programmer to cut the evolution time.
For Example, nosotros accept a CurrencyConverterForm in addition to nosotros don't wish a coffee class.
CurrencyConverterForm has properties fromCurrency, toCurrency
in the struts-config.xml file, declare the shape edible bean
CurrencyConverterForm has properties fromCurrency, toCurrency
in the struts-config.xml file, declare the shape edible bean
<form-bean name=" CurrencyConverterForm "
type="org.apache.struts.action.DynaActionForm">
<form-property name=" fromCurrency " type="java.lang.String"/>
<form-property name=" toCurrency " type="java.lang. String "/>
</form-bean>
Add action mapping inwards the struts-config.xml file:
<action path="/convertCurrency" type="com.techfaq.action.ConvertCurrencyAction"
name=" CurrencyConverterForm "
scope="request"
validate="true"
input="/pages/ currencyConverterform.jsp">
<forward name="success" path="/jsp/success.jsp"/>
<forward name="failure" path="/jsp/error.jsp" />
</action>
In the Action class.
type="org.apache.struts.action.DynaActionForm">
<form-property name=" fromCurrency " type="java.lang.String"/>
<form-property name=" toCurrency " type="java.lang. String "/>
</form-bean>
Add action mapping inwards the struts-config.xml file:
<action path="/convertCurrency" type="com.techfaq.action.ConvertCurrencyAction"
name=" CurrencyConverterForm "
scope="request"
validate="true"
input="/pages/ currencyConverterform.jsp">
<forward name="success" path="/jsp/success.jsp"/>
<forward name="failure" path="/jsp/error.jsp" />
</action>
In the Action class.
public shape ConvertCurrencyAction extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
DynaActionForm currencyConverterForm = (DynaActionForm)form;
// past times this way nosotros tin cry back the value which is laid inwards the JSP Page
String fromCurrency = (String) currencyConverterForm.get("fromCurrency ");
String toCurrency = (String) currencyConverterForm.get("toCurrency ");
return mapping.findForward("success");
}
}
}
In the JSP page
<html:text property=" fromCurrency " size="30" maxlength="30"/>
<html:text property=" toCurrency " size="30" maxlength="30"/>
Question 7: what the Validate () in addition to reset () method does?
Ans: This is i of my personal favorite Struts interview questions. validate(): validate method is Used to validate properties later they accept been populated, in addition to this , method is Called earlier FormBean is passed to Action. Returns a collection of ActionError equally ActionErrors. Following is the method signature for the validate() method.
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = novel ActionErrors();
if ( StringUtils.isNullOrEmpty(username) && StringUtils.isNullOrEmpty(password)){
errors.add(ActionErrors.GLOBAL_ERROR, novel ActionError("error.usernamepassword.required"));
}
return errors;
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = novel ActionErrors();
if ( StringUtils.isNullOrEmpty(username) && StringUtils.isNullOrEmpty(password)){
errors.add(ActionErrors.GLOBAL_ERROR, novel ActionError("error.usernamepassword.required"));
}
return errors;
}
reset(): reset() method is called past times Struts Framework amongst each asking that uses the defined ActionForm. The purpose of this method is to reset all of the ActionForm's information members prior to the novel asking values beingness set.
Example :
public void reset(ActionMapping mapping, HttpServletRequest request) {
this.password = null;
this.username = null;
}
Set zero for every request.
Example :
public void reset(ActionMapping mapping, HttpServletRequest request) {
this.password = null;
this.username = null;
}
Set zero for every request.
Question 8: How you lot volition brand available whatever Message Resources Definitions file to the Struts Framework Environment?
Ans: Message Resources Definitions file are uncomplicated .properties files in addition to these files incorporate the messages that tin live used inwards the struts project. Message Resources Definitions files tin live added to the struts-config.xml file through < message-resources / > tag. Example: < message-resources parameter= MessageResources / >
Message resources definition files tin available to the struts environs inwards 2 ways
1. using web.xml as
<servlet>
<servlet-name>action<servlet-name>
servlet-class>org.apache.struts.action.ActionServlet<servlet-class>
<init-param>
<param-name>application<param-name>
<param-value>resource.Application<param-value>
</servlet>
2.
<message-resource key="myResorce" parameter="resource.Application" null="false">
1. using web.xml as
<servlet>
<servlet-name>action<servlet-name>
servlet-class>org.apache.struts.action.ActionServlet<servlet-class>
<init-param>
<param-name>application<param-name>
<param-value>resource.Application<param-value>
</servlet>
2.
<message-resource key="myResorce" parameter="resource.Application" null="false">
Question 9: What configuration files are used inwards Struts?
Ans: ApplicationResources.properties in addition to struts-config.xml these 2 files are used to betwixt the Controller in addition to the Model.
Question 10: Explain Struts piece of occupation Flow?
Ans: Sometime this Struts interview questions asked equally rootage questions but I recall this straight off J . Here is the answer to this Struts interview questions
2) The ActionServlet having already read the struts-config.xml file knows which shape edible bean relates to this JSP, in addition to delegates piece of occupation to the validate method of that shape bean.
3) The shape edible bean performs the validate method to determine if all required fields accept been entered, in addition to performs whatever other types of patch validations that demand to live performed.
4) If whatever required patch has non been entered, or whatever patch does non transcend validation, the shape edible bean generates ActionErrors, in addition to later checking all fields returns dorsum to the ActionServlet.
5) The ActionServlet checks the ActionErrors that were returned from the shape beans validate method to determine if whatever errors accept occurred. If errors accept occurred, it returns to the originating JSP displaying the appropriate errors.
6) If no errors occurred inwards the validate method of the shape bean, the ActionServlet passes command to the appropriate Action class.
7) The Action shape performs whatever necessary draw of piece of occupation concern logic, in addition to and so forwards to the adjacent appropriate activity (probably around other JSP).
That’s all on Struts interview enquiry answers, for now, at that topographic point are lots many interview questions on Struts which I accept non covered which you lot guys tin contribute in addition to I volition include it here. If you lot are looking to abide by the reply to whatever enquiry asked on Struts interview then delight seat it hither in addition to I volition travail to abide by an reply to those questions.
Further Learning
Java Web Fundamentals By Kevin Jones
Struts 2 Framework for Beginners
Spring Framework Master Class - Beginner to Expert
Demikianlah Artikel Top X Struts Interview Interrogation Together With Answer - J2ee
Sekianlah artikel Top X Struts Interview Interrogation Together With Answer - J2ee kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.
Anda sekarang membaca artikel Top X Struts Interview Interrogation Together With Answer - J2ee dengan alamat link https://bestlearningjava.blogspot.com/2019/09/top-x-struts-interview-interrogation.html
Belum ada Komentar untuk "Top X Struts Interview Interrogation Together With Answer - J2ee"
Posting Komentar