Backend/src/main/java/com/devlin/prac/fetching_showing_data.java
<filename>Backend/src/main/java/com/devlin/prac/fetching_showing_data.javapackage com.devlin.prac;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

/**
 * Servlet implementation class Fetching_showing_data
 */
@WebServlet("/fetching_showing_data")
public class fetching_showing_data extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public fetching_showing_data() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//response.getWriter().append("Served at: ").append(request.getContextPath());
		
		DBconnection fetchdata=new DBconnection();
		ArrayList<winterInternshipDataSet> dep1=fetchdata.getData();
		
		Gson gson=new Gson();
		String respData=gson.toJson(dep1);
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.getWriter().print(respData);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}