Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use NetBeans Project Name: Project1Task4 You **MUST** use an MVC framework for t

ID: 3559087 • Letter: U

Question

Use NetBeans Project Name: Project1Task4 You **MUST** use an MVC framework for this project. For task 4, you will build a holiday gift suggestion application Etsy.com is an online marketplace primarily for artists and craftspersons to sell their work. It is also a great place to buy gifts for others. You are to build an application that will suggest gifts from Etsy for the holidays. When the user types in a holiday, you search Etsy.com and return a gift idea. In more detail: 1. The user is presented with a screen with instructions: "Welcome to the Etsy holiday gift suggester. What holiday would you like a gift suggestion for?" 2. The user types in a holiday, such as Groundhog's Day, Valentine's Day, Fourth of July, or Thanksgiving. Upon Submit, a servlet will search for a suitable gift on Etsy.com. 3. The following screenshot demonstrates a typical response. You should include all of the items indicated, but you are welcome to make the interface nicer if you have design skills.

Explanation / Answer

@WebServlet("/HolidayController")
public class HolidayController extends HttpServlet {
   private static final long serialVersionUID = 1L;
     
    /**
     * @see HttpServlet#HttpServlet()
     */
    public HolidayController() {
        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
   }

   /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
   protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       // TODO Auto-generated method stub
      
       String holiday=request.getParameter("holiday");
       Document doc;
       try {
  
          
           String url = "http://www.etsy.com/search?q="+holiday;
           doc = Jsoup.connect(url).get();
  

          
           Gift gift=new Gift();
           Elements images = doc.select(".listing-thumb").select("img[src~=(?i)\.(png|jpe?g|gif)]");
           Elements links = doc.select(".listing-thumb").select("a[href]");
          
           for (Element image:images) {
  
               System.out.println(" url : " + links.attr("href"));
               gift.setGiftUrl(links.attr("href"));
               System.out.println(" src : " + image.attr("src"));
               gift.setSrc(image.attr("src"));
               System.out.println("height : " + image.attr("height"));
               gift.setHeight(Integer.parseInt(image.attr("height")));
               System.out.println("width : " + image.attr("width"));
               gift.setWidth(Integer.parseInt(image.attr("width")));
               System.out.println("alt : " + image.attr("alt"));
               gift.setAlt(image.attr("alt"));
               gift.setHoliday(holiday);
               break;
  
           }
           request.setAttribute("gift", gift);
           RequestDispatcher rd=request.getRequestDispatcher("GiftSuggestion.jsp");
           rd.forward(request, response);
          
  
       } catch (IOException e) {
           e.printStackTrace();
       }
  
      
   }

package Bean;

public class Gift {

   String giftUrl;
   String holiday;
   String src;
   int height;
   int width;
   String alt;
   public String getGiftUrl() {
       return giftUrl;
   }
   public void setGiftUrl(String giftUrl) {
       this.giftUrl = giftUrl;
   }
   public String getHoliday() {
       return holiday;
   }
   public void setHoliday(String holiday) {
       this.holiday = holiday;
   }
   public String getSrc() {
       return src;
   }
   public void setSrc(String src) {
       this.src = src;
   }
   public int getHeight() {
       return height;
   }
   public void setHeight(int height) {
       this.height = height;
   }
   public int getWidth() {
       return width;
   }
   public void setWidth(int width) {
       this.width = width;
   }
   public String getAlt() {
       return alt;
   }
   public void setAlt(String alt) {
       this.alt = alt;
   }
  
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote