2 * Copyright (C) 2016 - 2020 Free Software Foundation
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.pizzaapplication.servlet.receipt;
19 import java.io.IOException;
20 import javax.faces.view.facelets.FaceletException;
21 import javax.naming.Context;
22 import javax.naming.InitialContext;
23 import javax.naming.NamingException;
24 import javax.servlet.ServletException;
25 import javax.servlet.http.HttpServlet;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
28 import org.mxchange.jshopcore.model.receipt.ReceiptBeanRemote;
29 import org.mxchange.jshopcore.model.receipt.WrapableReceipt;
32 * A servlet for a PDF receipt (official)
34 * @author Roland Häder<roland@mxchange.org>
36 public class PizzaPdfReceiptServlet extends HttpServlet {
41 private static final long serialVersionUID = 497_345_834_783_781L;
46 private ReceiptBeanRemote receiptBean;
51 public PizzaPdfReceiptServlet () {
54 // Get initial context
55 Context context = new InitialContext();
58 this.receiptBean = (ReceiptBeanRemote) context.lookup("java:global/jshop-ejb/pdf!org.mxchange.jshopcore.model.receipt.ReceiptBeanRemote"); //NOI18N
59 } catch (final NamingException e) {
61 throw new FaceletException(e);
66 public String getServletInfo () {
67 return "Produces a receipt as PDF file for given access key.";
71 protected void doGet (final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
73 if (request.getParameter("key") == null) { //NOI18N
74 // No more processing here
75 super.doGet(request, response);
80 WrapableReceipt receipt = this.receiptBean.createReceiptFromAccessKey(request.getParameter("key")); //NOI18N
82 // TODO Write it's content to response output
86 protected void doPost (final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
87 // Deligate to getter method
88 this.doGet(request, response);