+ "nbOfStories=nbOfStories\">Next page</a>\n</CENTER>\n");
+ "&nbOfStories="+nbOfStories+"\">Next page</a>\n</CENTER>\n");
  public void doGet(HttpServletRequest request, HttpServletResponse response)      throws IOException, ServletException  {    sp = new ServletPrinter(response, "BrowseStoriesByCategory");    conn = getConnection();    String categoryName, username, categoryId, testpage, testnbOfStories;    int page = 0, nbOfStories = 0;    ResultSet rs = null;    testpage = request.getParameter("page");    testnbOfStories = request.getParameter("nbOfStories");    if (testpage != null)    {      page = (Integer.valueOf(request.getParameter("page"))).intValue();    }    if (testnbOfStories != null)    {      nbOfStories = (Integer.valueOf(request.getParameter("nbOfStories")))          .intValue();    }    categoryId = request.getParameter("category");    categoryName = request.getParameter("categoryName");    if (categoryName == null)    {      sp.printHTML("Browse Stories By Category"          + "You must provide a category name!<br>");      return;    }    if (categoryId == null)    {      sp.printHTML("Browse Stories By Category"          + "You must provide a category identifier!<br>");      return;    }    if (page == 0)    {      page = 0;    }    if (nbOfStories == 0)    {      nbOfStories = 25;    }    sp.printHTMLheader("RUBBoS Browse Stories By Category");    sp.printHTML("<br><h2>Stories in category " + categoryName + "</h2><br>");    try    {      stmt = conn.prepareStatement("SELECT * FROM stories WHERE category= "          + categoryId + " ORDER BY date DESC LIMIT " + page * nbOfStories          + "," + nbOfStories);      rs = stmt.executeQuery();    }    catch (Exception e)    {      sp.printHTML("Failed to execute Query for BrowseStoriesByCategory: " + e);      closeConnection();      return;    }    try    {      if (!rs.first())      {        if (page == 0)        {          sp              .printHTML("<h2>Sorry, but there is no story available in this category !</h2>");        }        else        {          sp              .printHTML("<h2>Sorry, but there are no more stories available at this time.</h2><br>\n");          sp              .printHTML("<p><CENTER>\n<a href=\"/rubbos/servlet/edu.rice.rubbos.servlets.BrowseStoriesByCategory?category="                  + categoryId                  + "&categoryName="                  + URLEncoder.encode(categoryName)                  + "&page="                  + (page - 1)                  + "nbOfStories=nbOfStories\">Previous page</a>\n</CENTER>\n");        }        sp.printHTMLfooter();        closeConnection();        return;      }      do      {        String title = rs.getString("title");        String date = rs.getString("date");        username = rs.getString("writer");        int id = rs.getInt("id");        sp            .printHTML("<a href=\"/rubbos/servlet/edu.rice.rubbos.servlets.ViewStory?storyId="                + id                + "\">"                + title                + "</a> by "                + username                + " on "                + date                + "<br>\n");      }      while (rs.next());    }    catch (Exception e)    {      sp.printHTML("Exception getting categories: " + e + "<br>");      closeConnection();    }    if (page == 0)      sp          .printHTML("<p><CENTER>\n<a href=\"/rubbos/servlet/edu.rice.rubbos.servlets.BrowseStoriesByCategory?category="              + categoryId              + "&categoryName="              + URLEncoder.encode(categoryName)              + "&page="              + (page + 1)              + "nbOfStories=nbOfStories\">Next page</a>\n</CENTER>\n");    else      sp          .printHTML("<p><CENTER>\n<a href=\"/rubbos/servlet/edu.rice.rubbos.servlets.BrowseStoriesByCategory?category="              + categoryId              + "&categoryName="              + URLEncoder.encode(categoryName)              + "&page="              + (page - 1)              + "nbOfStories=nbOfStories\">Previous page</a>\n&nbsp&nbsp&nbsp"              + "<a href=\"/rubbos/servlet/edu.rice.rubbos.servlets.BrowseStoriesByCategory?category="              + categoryId              + "&categoryName="              + URLEncoder.encode(categoryName)              + "&page="              + (page + 1)              + "nbOfStories=nbOfStories\">Next page</a>\n\n</CENTER>\n");    sp.printHTMLfooter();  }