Brocade Communications Spring MVC Interview Questions

Brocade Communications Most Frequently Asked Spring MVC Latest Interview Questions Answers

How can you achieve Internationalization using MessageSource?

Internationnalization using message source can be achieved by the following :

1. String get Mesage(String code, Objct[] args, String default, Local loc) :
The basic method used for retrieving a message from the MessageSource. When no message is to be found for the specified locale, the default message is used.

2. String getMessage(String code, Objct[] args, Locale loc) :
Essentially the same as the last method, but with a difference, no default message is specified; if the message cannot be found, a NoSuchMessageException is shown.

3. String getMessage(MessageSourceResolvable resolvable, Local locale) :
Properties used for the preceding methods are also wrapped in a class named MessageSourceResolvable, which you can use with this method.
Brocade Communications Most Frequently Asked Spring MVC Latest Interview Questions Answers
Brocade Communications Most Frequently Asked Spring MVC Latest Interview Questions Answers

Enlist and explain the main methods associated with the Resource interface.

Methods associated with resource interface are as follows:

1. getInputStream() : It locates and opens the resource, returning an InputStream to read from the resource.

2. exists() : Returns a boolean which indicates whether this resource actually exists in physical form.

3. isOpen() : Returns a boolean which indicates whether this resource represents a handle with an open stream.

4. getDescription() : Returns a description for this resource, which is used for error output when working with the resource.

Give some examples where property editing is used in spring.

Following are the examples for property editing in spring :

1. Setting of properties on beans is done by using PropertyEditors. To mention java.lang.string as the value for a property of some bean you're declaring in XML file, Spring will use the ClassEditor to try resolving the parameter to a Class object.

2. Passing HTTP request parameters in Spring's MVC framework can be done using all kinds of PropertyEditors that can be manually bind in all subclasses of the CommandController.
Explain the main AOP concepts and terminology.

The main AOP concepts are as follows:

1. Aspect : A modularization of a concern that cuts through multiple classes.

2. Join point : It is a point during which the execution of a programming, such as the execution of method or handling of an exception.

3. Advice : An action taken by an aspect for a particular join point.

4. Point cut : A predicate that is matched to join points.

5. Introduction : Declaration of additional methods or fields on behalf of a type.

6. Target object : Object which is advised by one or more aspects.

7. AOP proxy : An object which is created by AOP framework for implementing the aspect contracts.

8. Weaving : Linking of aspects with other application types or objects to create an advised object.

How to upload file in Spring MVC Application?

Spring provides built-in support for uploading files through MultipartResolver interface implementations. It’s very easy to use and requires only configuration changes to get it working. Obviously we would need to write controller handler method to handle the incoming file and process it.

How to validate form data in Spring Web MVC Framework?

Spring supports JSR-303 annotation based validations as well as provide Validator interface that we can implement to create our own custom validator. For using JSR-303 based validation, we need to annotate bean variables with the required validations.

For custom validator implementation, we need to configure it in the controller class.

What is Spring MVC Interceptor and how to use it?

Spring MVC Interceptors are like Servlet Filters and allow us to intercept client request and process it. We can intercept client request at three places – preHandle, postHandle and afterCompletion.

We can create spring interceptor by implementing HandlerInterceptor interface or by extending abstract class HandlerInterceptorAdapter.

We need to configure interceptors in the spring bean configuration file. We can define an interceptor to intercept all the client requests or we can configure it for specific URI mapping too.

What is Spring JdbcTemplate class and how to use it?

Spring Framework provides excellent integration with JDBC API and provides JdbcTemplate utility class that we can use to avoid bolier-plate code from our database operations logic such as Opening/Closing Connection, ResultSet, PreparedStatement etc.

What is Aspect Oriented Programming (AOP)?

- Basically Aspect oriented programming complements object oriented programming by providing another way of programming model structure.
- In addition to classes, AOP gives you aspect, which enables modularization of concerns such as Transaction management or logging and can be separated out from the application business logic of the code (these kinds of concerns are termed as crosscutting concerns). AOP supports separating application business logic from System services.

Post a Comment

Previous Post Next Post