summaryrefslogtreecommitdiff
path: root/src/lq/ViewQuote.java
blob: 25755235a6c8cbcffe8f1432ec9645ea213580b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package lq;

import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ViewQuote extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {
        String idParam = req.getParameter("id");
        Long id = Long.parseLong(idParam);
        Quote quote = QuoteUtil.getQuoteWithId(id);

        resp.setContentType("text/html");

        if (quote != null) {
            Printer printer = new Printer(resp.getWriter());
            printer.printQuote(quote);
        }
        else {
            resp.getWriter().println("Quote not found."); 
        }
    }
}