Interview Questions


SpringBoot - Test

package hello;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

public class HelloController {
    private HelloService helloService;
    public String index() {
        return "Greetings from Spring Bootabc!" + helloService.getString();

package hello;

import org.springframework.stereotype.Service;


Spring Security REST Web Service Authentication

Spring Security REST Web service Authentication

Here is the code sample to authenticate REST Web service using SPring Security framework.


<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns=""
        xmlns:beans="" xmlns:xsi=""

Spring Security LDAP Configuration

Spring Security LDAP Configuration

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns=""
        xmlns:beans="" xmlns:xsi=""

Hasan_Sunasara's picture

Spring into Security with the Spring Security Framework

In Software programming, the use of frameworks makes things easy and saves a great deal of time for developers. In the Java world, Spring Security is one such framework that is worth consideration by developers. Spring Security is part of the larger Spring Projects Umbrella, and the framework can be used to implement security aspects in Java web applications. Spring Security makes a developer's job easier and ensures that an application is secure by configuring the appropriate elements in the XML file.

Spring 4 New Features

The following are some major features in Spring Framework 4 version

1.) Composable Annotations
2.) Autowiring with Generic
3.) HyperMedia (Rest WebServices  - Building links to controllers)
4.) Messaging and WebSockets
5.) JDK 8 Support

Spring 3.0 - Tutorial

Here come Spring 3.0 with support for @Annotations, reducing the overhead of bulk configuration files.

Spring Jdbc - NamedParameterJdbcTemplate

Here is a sample code to perform DB operation using NamedParameterJdbcTemplate API in Spring

Spring Jdbc - NamedParameterJdbcTemplate:

public class UserDao {
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;

public void createUser(User user) {
                Long userId =1001; //should be generated from a DB sequece
                String insertUserSql = "INSERT INTO DSM_USERS (USER_ID,LOGIN,PASSWORD,FIRST_NAME,"
                                + "LAST_NAME,PHONE_NUMBER,EMAIL,"
                                + "CREATED_DATE,GROUP_ID)"

Spring Security - Role based Url Authorization

It is a common aspect in a web application, to have a User Group management module, which is used to create users, groups, roles and also assign roles to users. Adding roles to Users, provides access restriction to that particular module at a logical level but not at the URL level.

For example, if a user is not allowed to view certain web pages in a module, usually that particular links will not be shown to user in the menu (or sub menu). At the same time the user should not be allowed access, when he tries to directly access the URL from browser.

Spring Security Configuration

This article provides details about configuring Spring Security in a Spring based Web application.

The following is the list of beans to be configured for Spring Security.


<beans:beans xmlns=""
        xmlns:beans="" xmlns:xsi=""
        xsi:schemaLocation=" ...">

        <!-- List of filters to be executed before processing any HTTP request for client/browser -->

Spring 3.0 Form Controller

To create a form controller in Spring 2.0 have a look at this article Simple Form Controller

In Spring 3.0, its much simpler to create form controllers. There is no need to extend any class (like SimpleFormController) to create a controller in Spring.

Have a look at the following Spring controller.

package in.techdive.web;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;