连接数据库和Ajax(无PHP)

I have to do a project as exam and I'm getting really troubled with this topic. My project is about a photoblog like Instagram. As in Instagram I want to get values from my DB and posting after the page has been loaded. So I've understood I need help from AJAX but every example I've found is about using PHP and I can't for my projects. Tools I can use are: HTML, CSS, XML, JQuery, AJAX, Servlet/JSP, DOM and JSON. I've found examples in PHP and I've tried to "translate" into Servlet/JSP but it (obviously) didn't work. This is my idea:

    $.ajax({ type: "GET",   
     url: "Jspfile",   
     success : function()
     {
        // Here I would like to use the return value from db that I got by a servlet/jsp file
     }
});

I'm using MySQL aS DB

You'll have to connect your Java applet to the database, then serialize the data from whatever object type your DB driver uses to JSON.

You then have to render the JSON in your "Jspfile" URL. Then, you just have to parse the JSON in your success / complete function in the jQuery request.