I am working on some Java Servlets, and basically i am outputting the results of an sql query to a table. I have some basic formatting for the table in the html code, but i also want to link a css file.
Whenever i link a stylesheet (even a blank one, or one with the same attributes as the html tags in the table), it just destroys any formatting in the table, and outputs the results as one continuous list.
Any suggestions at all would be a great help.
Here's my servlet code:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String category = request.getParameter("categoryname");
AlbumDAO albumData = new AlbumDAO();
ArrayList<AlbumBean> albums = albumData.findFromCategory(category);
PrintWriter out = response.getWriter();
response.setContentType("text/html");
String title = category + " albums";
String stylesheet = "<link rel=\"stylesheet\" type=\"text/css\" href=\"/CSS/stylesheet.css>";
out.println("<!DOCTYPE html><html>");
out.println("<head>");
out.println("<title>" + title + "</title>");
out.println(stylesheet);
out.println("</head>");
out.println("<body>");
out.println("<Center><H1>" + category + " albums</Center>");
out.println("<table border=\"1\" cellspacing=\"5\" cellpadding=\"5\">"
+ "<tr><th>ID</th><th>Artist</th><th>Title</th><th>Image Name</th><th>Tracks</th><th>Price</th><th>In Stock</th></tr>");
for (AlbumBean a : albums){
out.println("<tr><td> "+ a.getRecording_id() + "</td>");
out.println("<td>" + a.getArtist_name() + "</td>");
out.println("<td> " + a.getTitle() + "</td>");
out.println("<td> " + a.getCategory() + "</td>");
out.println("<td> " + a.getImage_name() + "</td>");
out.println("<td> " + a.getPrice() + "</td>");
out.println("<td> " + a.getStock_count() + "</td>");
out.println("</tr>");
}
out.println("</table>");
out.println("</body>");
out.println("<footer><a href = \"index.html\"> let's go home</a></footer>");
out.println("</html>");
}