save image in dam mediate a sling to then call it mediate another servlet
hi friends again here, I am now creating a node where I also want to save an image selected by the user in the dam to reuse but I have no idea how to perform this process due to the little knowledge I still have from the sling thanks for the collaboration and I appreciate very much all the help you can give me.
Here My Code
package com.globant.aem.gamer.store.core.servlets;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import javax.jcr.Node;
import javax.jcr.Session;
import javax.servlet.ServletException;
import java.io.IOException;
@SlingServlet(paths = {"/bin/gamer-store/tools/addGame"}, methods = {"GET"})
public class addGame extends SlingSafeMethodsServlet {
@Reference
ResourceResolverFactory resourceResolverFactory;
ResourceResolver resourceResolver;
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws ServletException, IOException {
try {
String category = request.getParameter("formCategory");
String name = request.getParameter("formName");
String price = request.getParameter("formPrice");
String publishDate = request.getParameter("formPublishDate");
String description = request.getParameter("formDescription");
resourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null);
Resource resource = resourceResolver.getResource("/content/gamerstore/games/" + category);
Session session = resourceResolver.adaptTo(Session.class);
Node nodeFather = resource.adaptTo(Node.class);
try {
Node nodeGame = nodeFather.addNode(name);
nodeGame.setProperty("category", category);
nodeGame.setProperty("name", name);
nodeGame.setProperty("price", price);
nodeGame.setProperty("publishDate", publishDate);
nodeGame.setProperty("description", description);
session.save();
} catch (Exception ex) {
}
} catch(Exception ex){
}
}
}
The idea is to have an image field and I do not know what should be kept in that field if the route of the dam to know that this image belongs to that node I appreciate the help that clarifies this doubt since I am not clear on how to do it already that after this the idea is to call the image to appear in a form

to then call the image and appear in each box of the image thank you for the help you can give me and I hope you have made me understand ![]()