GET and POST
- methods.
-
- @param request servlet request
- @param response servlet response
- @throws ServletException if a servlet-specific error occurs
- @throws IOException if an I/O error occurs
+ * Processes requests for both HTTP GET and POST
+ * methods.
+ *
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
*/
- protected void processRequest( HttpServletRequest request, HttpServletResponse response )
+ protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
- Command action = Command.from( request );
- String view = action.execute( request, response );
- request.getRequestDispatcher( "/WEB-INF/" + view + ".jsp" ).forward( request, response );
- } catch ( LoginSampleException ex ) {
- request.setAttribute( "error", ex.getMessage() );
- request.getRequestDispatcher( "index.jsp" ).forward( request, response );
+ /*HttpSession session = request.getSession();
+ String msg = (String) session.getAttribute("msg");
+ if (msg != null) {
+ out.println("");
+ session.setAttribute("msg", null);
+ }*/
+
+ Command action = Command.from(request);
+ String view = action.execute(request, response);
+ request.getRequestDispatcher("/WEB-INF/" + view + ".jsp").forward(request, response);
+ } catch (LoginSampleException ex) {
+ request.setAttribute("error", ex.getMessage());
+ request.getRequestDispatcher("index.jsp").forward(request, response);
+ }
+ catch (OrderException oex) {
+ request.setAttribute("error",oex.getMessage());
+ request.getRequestDispatcher("index.jsp").forward(request, response);
}
+
}
// GET method.
-
- @param request servlet request
- @param response servlet response
- @throws ServletException if a servlet-specific error occurs
- @throws IOException if an I/O error occurs
+ * Handles the HTTP GET method.
+ *
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
*/
@Override
- protected void doGet( HttpServletRequest request, HttpServletResponse response )
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- processRequest( request, response );
+ processRequest(request, response);
}
/**
- Handles the HTTP POST method.
-
- @param request servlet request
- @param response servlet response
- @throws ServletException if a servlet-specific error occurs
- @throws IOException if an I/O error occurs
+ * Handles the HTTP POST method.
+ *
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
*/
@Override
- protected void doPost( HttpServletRequest request, HttpServletResponse response )
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- processRequest( request, response );
+ processRequest(request, response);
}
/**
- Returns a short description of the servlet.
-
- @return a String containing servlet description
+ * Returns a short description of the servlet.
+ *
+ * @return a String containing servlet description
*/
@Override
public String getServletInfo() {
diff --git a/src/main/java/PresentationLayer/Help.java b/src/main/java/PresentationLayer/Help.java
new file mode 100644
index 0000000..a67f39e
--- /dev/null
+++ b/src/main/java/PresentationLayer/Help.java
@@ -0,0 +1,26 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package PresentationLayer;
+
+import FunctionLayer.LogicFacade;
+import FunctionLayer.LoginSampleException;
+import FunctionLayer.User;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+/**
+ *
+ * @author juanni420
+ */
+public class Help extends Command {
+
+ @Override
+ String execute(HttpServletRequest request, HttpServletResponse response) throws LoginSampleException {
+ return "help";
+ }
+
+}
diff --git a/src/main/java/PresentationLayer/Login.java b/src/main/java/PresentationLayer/Login.java
index ffe06f5..f674697 100644
--- a/src/main/java/PresentationLayer/Login.java
+++ b/src/main/java/PresentationLayer/Login.java
@@ -9,7 +9,6 @@
/**
The purpose of Login is to...
-
@author kasper
*/
public class Login extends Command {
@@ -25,4 +24,4 @@ String execute( HttpServletRequest request, HttpServletResponse response ) throw
return user.getRole() + "page";
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/PresentationLayer/Order.java b/src/main/java/PresentationLayer/Order.java
new file mode 100644
index 0000000..1b2c4ad
--- /dev/null
+++ b/src/main/java/PresentationLayer/Order.java
@@ -0,0 +1,26 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package PresentationLayer;
+
+import FunctionLayer.LogicFacade;
+import FunctionLayer.LoginSampleException;
+import FunctionLayer.User;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+/**
+ *
+ * @author juanni420
+ */
+public class Order extends Command {
+
+ @Override
+ String execute(HttpServletRequest request, HttpServletResponse response) throws LoginSampleException {
+ return "order";
+ }
+
+}
diff --git a/src/main/java/PresentationLayer/Orders.java b/src/main/java/PresentationLayer/Orders.java
new file mode 100644
index 0000000..8f51477
--- /dev/null
+++ b/src/main/java/PresentationLayer/Orders.java
@@ -0,0 +1,35 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package PresentationLayer;
+
+import FunctionLayer.LogicFacade;
+import FunctionLayer.LoginSampleException;
+import FunctionLayer.OrderEntity;
+import FunctionLayer.OrderException;
+import FunctionLayer.User;
+import java.util.ArrayList;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+/**
+ *
+ * @author juanni420
+ */
+public class Orders extends Command{
+
+ @Override
+ String execute(HttpServletRequest request, HttpServletResponse response) throws LoginSampleException, OrderException {
+ ArrayListOrder
+ <%out.println("Length: " + order.getLength() + + ", Width: " + order.getWidth() + ", Height: " + order.getHeight() + "
");%> +The door and window are both 2 dots wide
+The door is 3 bricks high; The window is 1 brick high.
+If you'll notice am i only subtracting the door and window height from 2x2 bricks. + That's because both the window and door is 2 dots wide, so we've swapped 4 2x2 bricks in place for the door and window.
+| Side | +1x2 | +2x2 | +2x4 | +Dør | +Vindue | + <% int brick1sum = 0, brick2sum = 0, brick3sum = 0; + int door = 0, window = 0, doorheight = 0, windowheight = 0; + for (Side side : sideList) { + int brick1 = 0, brick2 = 0, brick3 = 0; + door = 0; + window = 0; + out.println("
| " + side.getName() + " | "); + for (Brick brick : side.getBricks()) { + if (brick.getName().equals("1x2")) { + brick1++; + brick1sum++; + } + if (brick.getName().equals("2x2")) { + brick2++; + brick2sum++; + } + if (brick.getName().equals("2x4")) { + brick3++; + brick3sum++; + } + if (brick.getName().equals("Door")) { + door++; + doorheight = brick.getHeight(); + } + if (brick.getName().equals("Window")) { + window++; + windowheight = brick.getHeight(); + } + } + out.println("" + brick1 + " | "); + out.println("" + brick2 + " | "); + out.println("" + brick3 + " | "); + out.println("" + door + " | "); + out.println("" + window + " | "); + + } + %> + +
| (ialt x H) - dørH - vindueH | +<%= (brick1sum * order.getHeight())%> | +<%= (brick2sum * order.getHeight() - doorheight - windowheight)%> | +<%= (brick3sum * order.getHeight())%> | +
You are now logged in as a customer of our wonderful site.
+ Klik her får at komme til bestillingssiden + Klik her får at se dine bestillinger +Order Id: " + order.getId() + ", Length: " + order.getLength() + + ", Width: " + order.getWidth() + ", Height: " + order.getHeight() + + ", User Email: " + order.getEmail() + ", Status: " + order.getStatus() + "
"); + } + %> +You are now logged in as a EMPLOYEE of our wonderful site.
+ Klik her får at se alle bestillinger +Du skal først og fremest logge ind på siden, og hvis ikke du har en bruger skal du oprette dig.
+ Klik på 'Order LegoHouse' oppe i menuen.
+ Når du så er på siden skal du bare indtaste en bredde, længde og højde af det hus du vil have.
+ Så udgiver vores system en liste af de klodser der skal bruges til at bygge huset.
| Login | ++ + | +Or Register | ++ + | +
Du er logget ind og klar til at bestille Lego!
"); + }%> + + + Få hjælp til din bestilling +| Order | ++ + | +
Order Id: " + order.getId() + ", Length: " + order.getLength() + + ", Width: " + order.getWidth() + ", Height: " + order.getHeight() + + ", Status: " + order.getStatus() + "
"); + } + %> +Order
+ <%out.println("Length: " + order.getLength() + + ", Width: " + order.getWidth() + ", Height: " + order.getHeight() + "
");%> +The door and window are both 2 dots wide
+The door is 3 bricks high; The window is 1 brick high.
+If you'll notice am i only subtracting the door and window height from 2x2 bricks. + That's because both the window and door is 2 dots wide, so we've swapped 4 2x2 bricks in place for the door and window.
+| Side | +1x2 | +2x2 | +2x4 | +Dør | +Vindue | + <% int brick1sum = 0, brick2sum = 0, brick3sum = 0; + int door = 0, window = 0, doorheight = 0, windowheight = 0; + for (Side side : sideList) { + int brick1 = 0, brick2 = 0, brick3 = 0; + door = 0; + window = 0; + out.println("
| " + side.getName() + " | "); + for (Brick brick : side.getBricks()) { + if (brick.getName().equals("1x2")) { + brick1++; + brick1sum++; + } + if (brick.getName().equals("2x2")) { + brick2++; + brick2sum++; + } + if (brick.getName().equals("2x4")) { + brick3++; + brick3sum++; + } + if (brick.getName().equals("Door")) { + door++; + doorheight = brick.getHeight(); + } + if (brick.getName().equals("Window")) { + window++; + windowheight = brick.getHeight(); + } + } + out.println("" + brick1 + " | "); + out.println("" + brick2 + " | "); + out.println("" + brick3 + " | "); + out.println("" + door + " | "); + out.println("" + window + " | "); + + } + %> + +
| (ialt x H) - dørH - vindueH | +<%= (brick1sum * order.getHeight())%> | +<%= (brick2sum * order.getHeight() - doorheight - windowheight)%> | +<%= (brick3sum * order.getHeight())%> | +
| Login | -- - | -Or Register | -- - | -
<%= error %> - <% } - %> + <%@include file="WEB-INF/nav.jsp" %> +
This is the front page of my Lego House site.
+ + Få hjælp til din bestilling + + <% String error = (String) request.getAttribute("error"); + if (error != null) {%> +<%= error%> + <% } + %> +