package edu.neumont.java.playlistpug;

import java.io.IOException;

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

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

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String destination = request.getPathInfo();
		String[] path = null;
		if(request.getPathInfo() == null || request.getPathInfo().equals("")){
			destination = "/WEB-INF/index.jsp";
		}else{
			path = request.getPathInfo().substring(1).split("/");
			Boolean b = destination.equals("/");
			if(destination.equals("/") || path[0].equals("index") || path[0].equals("main") || path[0].equals("home")){
				destination = "/WEB-INF/index.jsp";
			}else if(path[0].equals("upload")){
				destination = "/WEB-INF/upload.jsp";
			}else if(path[0].equals("song")){
				//set attributes name as the name of the song and
				//song as whatever is needed to play the song
				request.setAttribute("name", "song name");
				request.setAttribute("song", "song data");
				destination = "/WEB-INF/song.jsp";
			}else if(path[0].equals("search")){
				//depends on how we decide to do the searching
				//may set attribute to search terms or list of search results
				request.setAttribute("search_terms_or_results", "");
				destination = "/WEB-INF/search.jsp";
			}
		}
		RequestDispatcher rd = request.getRequestDispatcher(destination);
		rd.forward(request, response);
	}

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

}
@@ -884,37 +884,18 @@
 ation = 
-request.getPathInfo()
+%22%22
 ;%0A%09%09Stri
@@ -1097,78 +1097,11 @@
 %0A%09%09%09
-Boolean b = destination.equals(%22/%22);%0A%09%09%09if(destination.equals(%22/%22) %7C%7C 
+if(
 path
@@ -2194,8 +2194,9 @@
 ub%0A%09%7D%0A%0A%7D
+%0A

Revert "GET and Home complete"