Back to project page droidBBpush.
The source code is released under:
This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...
If you think the Android project droidBBpush listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.arg3.examples.push; /*from w ww . j av a 2 s . c o m*/ import com.arg3.examples.push.dao.DeviceDAO; import com.arg3.examples.push.model.Device; import java.io.IOException; import java.sql.SQLException; import java.util.List; import javax.inject.Inject; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Created by c0der78 on 2014-09-19. */ public class PushServlet extends BaseServlet { @Inject DeviceDAO deviceDAO; @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { try { List<Device> devices = deviceDAO.findAllDevices(); req.setAttribute("devices", devices); req.getRequestDispatcher("/index.ftl").forward(req, resp); } catch (SQLException e) { e.printStackTrace(); } } @Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { String deviceId = req.getParameter("deviceId"); if (deviceId == null || deviceId.isEmpty()) { addFlashError(req, "device not found"); } else try { deviceDAO.remove(Integer.valueOf(deviceId)); } catch (SQLException e) { throw new ServletException("Unable to remove device", e); } resp.sendRedirect("/push"); } }