@@ -0,0 +1,2736 @@
+/*%0D%0A * To change this license header, choose License Headers in Project Properties.%0D%0A * To change this template file, choose Tools %7C Templates%0D%0A * and open the template in the editor.%0D%0A */%0D%0A%0D%0Aimport com.mysql.jdbc.Connection;%0D%0Aimport java.io.IOException;%0D%0Aimport java.io.PrintWriter;%0D%0Aimport java.sql.*;%0D%0Aimport javax.servlet.ServletException;%0D%0Aimport javax.servlet.annotation.WebServlet;%0D%0Aimport javax.servlet.http.HttpServlet;%0D%0Aimport javax.servlet.http.HttpServletRequest;%0D%0Aimport javax.servlet.http.HttpServletResponse;%0D%0A%0D%0A/**%0D%0A *%0D%0A * @author Himasha%0D%0A */%0D%0A@WebServlet(urlPatterns = %7B%22/FruitBox%22%7D)%0D%0Apublic class FruitBox extends HttpServlet %7B%0D%0A%0D%0A    /**%0D%0A     * Processes requests for both HTTP %3Ccode%3EGET%3C/code%3E and %3Ccode%3EPOST%3C/code%3E%0D%0A     * methods.%0D%0A     *%0D%0A     * @param request servlet request%0D%0A     * @param response servlet response%0D%0A     * @throws ServletException if a servlet-specific error occurs%0D%0A     * @throws IOException if an I/O error occurs%0D%0A     */%0D%0A    %0D%0A%0D%0A    // %3Ceditor-fold defaultstate=%22collapsed%22 desc=%22HttpServlet methods. Click on the + sign on the left to edit the code.%22%3E%0D%0A    /**%0D%0A     * Handles the HTTP %3Ccode%3EGET%3C/code%3E method.%0D%0A     *%0D%0A     * @param request servlet request%0D%0A     * @param response servlet response%0D%0A     * @throws ServletException if a servlet-specific error occurs%0D%0A     * @throws IOException if an I/O error occurs%0D%0A     */%0D%0A    @Override%0D%0A    protected void doGet(HttpServletRequest request, HttpServletResponse response)%0D%0A            throws ServletException, IOException %7B%0D%0A        //processRequest(request, response);%0D%0A        %0D%0A        response.setContentType(%22text/html%22);%0D%0A        PrintWriter out = response.getWriter();%0D%0A        %0D%0A        try%7B%0D%0A            Class.forName(%22com.mysql.jdbc.Driver%22);%0D%0A            Connection con = (Connection) DriverManager.getConnection(%22jdbc:mysql://localhost:3306/fruitbox%22,%22root%22,%22%22);%0D%0A            Statement statement = con.createStatement();%0D%0A        %7Dcatch(Exception e)%7B%0D%0A        %7D%0D%0A        %0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * Handles the HTTP %3Ccode%3EPOST%3C/code%3E method.%0D%0A     *%0D%0A     * @param request servlet request%0D%0A     * @param response servlet response%0D%0A     * @throws ServletException if a servlet-specific error occurs%0D%0A     * @throws IOException if an I/O error occurs%0D%0A     */%0D%0A    @Override%0D%0A    protected void doPost(HttpServletRequest request, HttpServletResponse response)%0D%0A            throws ServletException, IOException %7B%0D%0A        //processRequest(request, response);%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * Returns a short description of the servlet.%0D%0A     *%0D%0A     * @return a String containing servlet description%0D%0A     */%0D%0A    @Override%0D%0A    public String getServletInfo() %7B%0D%0A        return %22Short description%22;%0D%0A    %7D// %3C/editor-fold%3E%0D%0A%0D%0A%7D%0D%0A

connect to db