Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package eu.kristinaeapost.kommid.controller;
- import java.io.IOException;
- import java.util.List;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import eu.kristinaeapost.kommid.db.CandyDAO;
- import eu.kristinaeapost.kommid.model.Candy;
- public class CandyServlet extends HttpServlet {
- protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- if(request.getParameter("id") != null) {
- long id = Long.parseLong(request.getParameter("id"));
- Candy candy = CandyDAO.findCandyById(id);
- request.setAttribute("candy", candy);
- request.getRequestDispatcher("/WEB-INF/candy.jsp").forward(request, response);
- }
- else {
- List<Candy> candies = CandyDAO.findAllCandies();
- request.setAttribute("candies", candies);
- request.getRequestDispatcher("/WEB-INF/candies.jsp").forward(request, response);
- }
- }
- protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- String id = request.getParameter("id");
- String name = request.getParameter("candy_name");
- String weight = request.getParameter("weight");
- String filling = request.getParameter("filling");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement