I have this one controller that serves up all the webpages and any dynamic content. Is this the most efficient way of doing this? Can it be improved?

package uk.co.morleys;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

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 HomeController
 */
@WebServlet("/HomeController")
public class HomeController extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private TestimonialService testimonialService;
    private PriceService priceService;
    private String page, views;
    private int pageNum;
    List&lt;Testimonial&gt; testimonialList;
    List&lt;Price&gt; priceList;
    List&lt;Paginator&gt; paginationList  = new ArrayList&lt;Paginator&gt;();
    RequestDispatcher rd;


    public HomeController(){
        testimonialService  = new TestimonialService();
        priceService        = new PriceService();
        views               = "/WEB-INF/views/";
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        page    = request.getParameter("page");
        pageNum = (request.getParameter("pageNum") == null )? 1: Integer.parseInt(request.getParameter("pageNum"));
        int perPage = 6;
        if(page != null){
            switch (page){
            case "home":

                // get list of testimonials
                testimonialList = testimonialService.getTestimonials(2);

                // pass list of testimonials to the request object
                request.setAttribute("testimonialList", testimonialList);

                rd = getServletContext().getRequestDispatcher(views + "index.jsp");
                rd.forward(request, response);
                break;
            case "about":

                // get list of prices
                priceList = priceService.getPrices();

                // pass list of prices to the request object
                request.setAttribute("priceList", priceList);

                rd = getServletContext().getRequestDispatcher(views + "about.jsp");
                rd.forward(request, response);
                break;
            case "contact":
                rd = getServletContext().getRequestDispatcher(views + "contact.jsp");
                rd.forward(request, response);
                break;
            case "theory":
                rd = getServletContext().getRequestDispatcher(views + "theory.jsp");
                rd.forward(request, response);
                break;
            case "testimonials":

                // get list of testimonials
                testimonialList = testimonialService.getTestimonials(pageNum, perPage);

                // get pagination details
                paginationList = testimonialService.getPaginationDetails(pageNum, perPage);

                // pass list of testimonials to the request object
                request.setAttribute("paginationList", paginationList);
                request.setAttribute("testimonialList", testimonialList);
                request.setAttribute("perPage", perPage);

                rd = getServletContext().getRequestDispatcher(views + "testimonials.jsp");
                rd.forward(request, response);
                break;
            case "":
                rd = getServletContext().getRequestDispatcher(views + "index.jsp");
                rd.forward(request, response);
                break;
            case " ":
                rd = getServletContext().getRequestDispatcher(views + "index.jsp");
                rd.forward(request, response);
                break;
            default:
                rd = getServletContext().getRequestDispatcher(views + "index.jsp");
                rd.forward(request, response);
                break;
            }
        }else{
            rd = getServletContext().getRequestDispatcher(views + "index.jsp");
            rd.forward(request, response);
        }
    }
}



Question: Making sure that you have comprehended a concept
Answer: Although we all want to "understand the concepts", I would encourage you to measure how well you are learning mathematics not by whether you "understand a concept" or not (because this is in the end too vaguely defined) but by whether you can use what you have learned to do something useful. For students, this usually means doing the problems at the end of the section or chapter. For those using mathematics as a tool (like Steve Huntsman), it means writing software that uses the mathematics learned. For both students and professionals, it also often means working out the details usually via computations of examples that illustrate what you have just learned. And, of course, if you are or are striving to be a pure mathematician, it can also mean using what you learned to prove other mathematical statements you want or need.

If you are able to do any of these things with what you have just learned, then you should definitely move along to the next thing. Because, as others have already advised you, you might want to move along, even if you can't do anything useful yet. When learning mathematics, you should definitely try to be able to do something useful (e.g., work out examples and/or solve problems) with most of what you are learning. However, everybody runs into things that just don't sink in despite intensive effort. As long as you're learning most of everything else, it is often advisable to just move ahead and return later after you know more and are more experienced. Everything gets easier, if not on the second try, usually by the tenth.