From 569201df71075558e62134b3215e85d8eec40fbb Mon Sep 17 00:00:00 2001 From: Zach Gulde Date: Thu, 1 Dec 2016 18:06:13 -0600 Subject: [PATCH 01/16] initial commit - pom.xml setup to include servlets - skeleton of a hello world servlet --- .gitignore | 3 +++ pom.xml | 34 ++++++++++++++++++++++++++++ src/main/java/HelloWorldServlet.java | 9 ++++++++ 3 files changed, 46 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/HelloWorldServlet.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..a65bf3836e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.iml +target/ +.idea/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000..4782732164 --- /dev/null +++ b/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + com.codeup.adlister + adlister + 1.0-SNAPSHOT + war + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + + + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + + + + \ No newline at end of file diff --git a/src/main/java/HelloWorldServlet.java b/src/main/java/HelloWorldServlet.java new file mode 100644 index 0000000000..dd49fb7133 --- /dev/null +++ b/src/main/java/HelloWorldServlet.java @@ -0,0 +1,9 @@ +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class HelloWorldServlet extends HttpServlet { + protected void doGet(HttpServletRequest req, HttpServletResponse res) { + + } +} From ca060b895a051e3e44e44e098fd356e256e6800f Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Wed, 26 May 2021 12:31:03 -0500 Subject: [PATCH 02/16] feat: Servlet_exercises completed --- src/main/java/CounterServlet.java | 25 +++++++++++++++++++++++++ src/main/java/HelloWorldServlet.java | 17 ++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/main/java/CounterServlet.java diff --git a/src/main/java/CounterServlet.java b/src/main/java/CounterServlet.java new file mode 100644 index 0000000000..2dc8a02084 --- /dev/null +++ b/src/main/java/CounterServlet.java @@ -0,0 +1,25 @@ +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@WebServlet( name = "CounterServlet", urlPatterns = "/count") +public class CounterServlet extends HttpServlet { + int count = 0; + + protected void doGet(HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException { + String reset = req.getParameter("reset"); + if(reset != null){ + count = 0; + } + + count++; + res.getWriter().println("this page has been visited " + count + " times!"); + + + } + +} + diff --git a/src/main/java/HelloWorldServlet.java b/src/main/java/HelloWorldServlet.java index dd49fb7133..d7fc437503 100644 --- a/src/main/java/HelloWorldServlet.java +++ b/src/main/java/HelloWorldServlet.java @@ -1,9 +1,24 @@ +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +@WebServlet( name = "HelloWorldServlet", urlPatterns = "/hello") public class HelloWorldServlet extends HttpServlet { - protected void doGet(HttpServletRequest req, HttpServletResponse res) { + + + protected void doGet(HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException { + String name = req.getParameter("name"); + if( name == null){ + name = "World"; + res.getWriter().println("

Hello World

"); + } + + res.getWriter().println("

hello, " + name + " !

"); + } + } From 669b1a6551d65fa9f10dfe40bb5c9ae23c3e323c Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Wed, 26 May 2021 12:36:02 -0500 Subject: [PATCH 03/16] feat: completed exercises for servlets --- src/main/java/CounterServlet.java | 2 +- src/main/java/HelloWorldServlet.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/CounterServlet.java b/src/main/java/CounterServlet.java index 2dc8a02084..6dd83b67b3 100644 --- a/src/main/java/CounterServlet.java +++ b/src/main/java/CounterServlet.java @@ -8,7 +8,7 @@ @WebServlet( name = "CounterServlet", urlPatterns = "/count") public class CounterServlet extends HttpServlet { int count = 0; - +//added protected void doGet(HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException { String reset = req.getParameter("reset"); if(reset != null){ diff --git a/src/main/java/HelloWorldServlet.java b/src/main/java/HelloWorldServlet.java index d7fc437503..1364967e12 100644 --- a/src/main/java/HelloWorldServlet.java +++ b/src/main/java/HelloWorldServlet.java @@ -7,7 +7,7 @@ @WebServlet( name = "HelloWorldServlet", urlPatterns = "/hello") public class HelloWorldServlet extends HttpServlet { - +//added protected void doGet(HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException { String name = req.getParameter("name"); From b0ff110c0a9fc48279c06cf7243147f46b139a62 Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Thu, 27 May 2021 13:52:48 -0500 Subject: [PATCH 04/16] feat: JSP and JSTL lecture --- pom.xml | 6 +++ src/main/java/CounterServlet.java | 1 - src/main/webapp/css/styles.css | 6 +++ src/main/webapp/index.jsp | 18 +++++++++ src/main/webapp/js/scripts.js | 1 + src/main/webapp/partials/navbar.jsp | 14 +++++++ src/main/webapp/welcome.jsp | 60 +++++++++++++++++++++++++++++ 7 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/main/webapp/css/styles.css create mode 100644 src/main/webapp/index.jsp create mode 100644 src/main/webapp/js/scripts.js create mode 100644 src/main/webapp/partials/navbar.jsp create mode 100644 src/main/webapp/welcome.jsp diff --git a/pom.xml b/pom.xml index 4782732164..aac788ff3b 100644 --- a/pom.xml +++ b/pom.xml @@ -29,6 +29,12 @@ javax.servlet-api 3.0.1 + + jstl + jstl + 1.2 + + \ No newline at end of file diff --git a/src/main/java/CounterServlet.java b/src/main/java/CounterServlet.java index 6dd83b67b3..04225dd566 100644 --- a/src/main/java/CounterServlet.java +++ b/src/main/java/CounterServlet.java @@ -8,7 +8,6 @@ @WebServlet( name = "CounterServlet", urlPatterns = "/count") public class CounterServlet extends HttpServlet { int count = 0; -//added protected void doGet(HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException { String reset = req.getParameter("reset"); if(reset != null){ diff --git a/src/main/webapp/css/styles.css b/src/main/webapp/css/styles.css new file mode 100644 index 0000000000..1682cb34ce --- /dev/null +++ b/src/main/webapp/css/styles.css @@ -0,0 +1,6 @@ +body{ + background-color: cornflowerblue; +} +h1{ + color: lightskyblue; +} \ No newline at end of file diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp new file mode 100644 index 0000000000..620be33cb0 --- /dev/null +++ b/src/main/webapp/index.jsp @@ -0,0 +1,18 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/27/21 + Time: 10:34 AM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Adlister + + +<%@ include file="partials/navbar.jsp" %> + +

All Ads

+ + diff --git a/src/main/webapp/js/scripts.js b/src/main/webapp/js/scripts.js new file mode 100644 index 0000000000..e8415d4730 --- /dev/null +++ b/src/main/webapp/js/scripts.js @@ -0,0 +1 @@ +console.log("It works!!") \ No newline at end of file diff --git a/src/main/webapp/partials/navbar.jsp b/src/main/webapp/partials/navbar.jsp new file mode 100644 index 0000000000..0f185869f2 --- /dev/null +++ b/src/main/webapp/partials/navbar.jsp @@ -0,0 +1,14 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/27/21 + Time: 10:39 AM + To change this template use File | Settings | File Templates. +--%> + \ No newline at end of file diff --git a/src/main/webapp/welcome.jsp b/src/main/webapp/welcome.jsp new file mode 100644 index 0000000000..8080970aa8 --- /dev/null +++ b/src/main/webapp/welcome.jsp @@ -0,0 +1,60 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/27/21 + Time: 9:58 AM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + Welcome, Marco + <%--must remember to not have any servlets listening on root --%> + + + +<%@ include file="partials/navbar.jsp" %> +<% int counter = 0; %> + <% counter++; + request.setAttribute("age",24); + request.setAttribute("numbers",new int[] { 1,2,3,4,5,6}); + %> + +

Hello, Marco

+ +What is 1+1? <%= 1+1 %> would be the answer. + +

This page was requested using the method <%=request.getMethod()%>

+

Path: <%=request.getRequestURL()%>

+

Name of parameter in query string <%=request.getParameter("name")%>

+

name: ${param.name}

+ +

Kelvon is ${age} years old

+
This page has been viewed <%=counter %> times
+ +<%----%> +<%-- Neopets for the win!--%> +<%----%> + +<%----%> +<%--

You really should go find stuff

--%> +<%-- Google--%> +<%--
--%> + + +
  • Item number ${number}
  • +
    + + + + Neopets for the win! + + + Google + + + + + + From 363aaa4dac3d16c5ede7a4a9f0c3e0af837afe13 Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Thu, 27 May 2021 14:15:01 -0500 Subject: [PATCH 05/16] feat : JSP/JSTL --- src/main/webapp/login.jsp | 16 ++++++++++++++++ src/main/webapp/profile.jsp | 16 ++++++++++++++++ src/main/webapp/welcome.jsp | 4 ++-- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 src/main/webapp/login.jsp create mode 100644 src/main/webapp/profile.jsp diff --git a/src/main/webapp/login.jsp b/src/main/webapp/login.jsp new file mode 100644 index 0000000000..8eed57cf9f --- /dev/null +++ b/src/main/webapp/login.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/27/21 + Time: 2:01 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + + + + diff --git a/src/main/webapp/profile.jsp b/src/main/webapp/profile.jsp new file mode 100644 index 0000000000..8eed57cf9f --- /dev/null +++ b/src/main/webapp/profile.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/27/21 + Time: 2:01 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + + + + diff --git a/src/main/webapp/welcome.jsp b/src/main/webapp/welcome.jsp index 8080970aa8..40f859add3 100644 --- a/src/main/webapp/welcome.jsp +++ b/src/main/webapp/welcome.jsp @@ -41,11 +41,11 @@ What is 1+1? <%= 1+1 %> would be the answer. <%--

    You really should go find stuff

    --%> <%-- Google--%> <%----%> - +
    • Item number ${number}
    • - +
    Neopets for the win! From b149daf984fcf2862ac9aeecd07277342711df28 Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Thu, 27 May 2021 14:34:39 -0500 Subject: [PATCH 06/16] completed: JSP/JSTL Lec --- src/main/java/HelloWorldServlet.java | 2 +- src/main/webapp/login.jsp | 16 ---------------- src/main/webapp/profile.jsp | 16 ---------------- 3 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 src/main/webapp/login.jsp delete mode 100644 src/main/webapp/profile.jsp diff --git a/src/main/java/HelloWorldServlet.java b/src/main/java/HelloWorldServlet.java index 1364967e12..ad8c88d392 100644 --- a/src/main/java/HelloWorldServlet.java +++ b/src/main/java/HelloWorldServlet.java @@ -7,7 +7,7 @@ @WebServlet( name = "HelloWorldServlet", urlPatterns = "/hello") public class HelloWorldServlet extends HttpServlet { -//added +//added comment protected void doGet(HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException { String name = req.getParameter("name"); diff --git a/src/main/webapp/login.jsp b/src/main/webapp/login.jsp deleted file mode 100644 index 8eed57cf9f..0000000000 --- a/src/main/webapp/login.jsp +++ /dev/null @@ -1,16 +0,0 @@ -<%-- - Created by IntelliJ IDEA. - User: Kelvon - Date: 5/27/21 - Time: 2:01 PM - To change this template use File | Settings | File Templates. ---%> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - Title - - - - - diff --git a/src/main/webapp/profile.jsp b/src/main/webapp/profile.jsp deleted file mode 100644 index 8eed57cf9f..0000000000 --- a/src/main/webapp/profile.jsp +++ /dev/null @@ -1,16 +0,0 @@ -<%-- - Created by IntelliJ IDEA. - User: Kelvon - Date: 5/27/21 - Time: 2:01 PM - To change this template use File | Settings | File Templates. ---%> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - Title - - - - - From 7be53f27fb427b2af1e05ab4750245a6999b59e3 Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Thu, 27 May 2021 16:09:35 -0500 Subject: [PATCH 07/16] feat: Build Login Form --- src/main/webapp/login.jsp | 16 ++++++++++++++++ src/main/webapp/profile.jsp | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/main/webapp/login.jsp create mode 100644 src/main/webapp/profile.jsp diff --git a/src/main/webapp/login.jsp b/src/main/webapp/login.jsp new file mode 100644 index 0000000000..d93cfd49c9 --- /dev/null +++ b/src/main/webapp/login.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/27/21 + Time: 2:56 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + $Title$ + + + $END$ + + diff --git a/src/main/webapp/profile.jsp b/src/main/webapp/profile.jsp new file mode 100644 index 0000000000..d93cfd49c9 --- /dev/null +++ b/src/main/webapp/profile.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/27/21 + Time: 2:56 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + $Title$ + + + $END$ + + From 336d0be38bfa7641d174c69eb7700cf04dff4c13 Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Thu, 27 May 2021 16:17:06 -0500 Subject: [PATCH 08/16] feat: Build Website Template --- src/main/webapp/partials/body.jsp | 16 ++++++++++++++++ src/main/webapp/partials/footer.jsp | 16 ++++++++++++++++ src/main/webapp/partials/head.jsp | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/main/webapp/partials/body.jsp create mode 100644 src/main/webapp/partials/footer.jsp create mode 100644 src/main/webapp/partials/head.jsp diff --git a/src/main/webapp/partials/body.jsp b/src/main/webapp/partials/body.jsp new file mode 100644 index 0000000000..e70039f482 --- /dev/null +++ b/src/main/webapp/partials/body.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/27/21 + Time: 4:12 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + $Title$ + + + $END$ + + diff --git a/src/main/webapp/partials/footer.jsp b/src/main/webapp/partials/footer.jsp new file mode 100644 index 0000000000..de36cdddb9 --- /dev/null +++ b/src/main/webapp/partials/footer.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/27/21 + Time: 4:15 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + $Title$ + + + $END$ + + diff --git a/src/main/webapp/partials/head.jsp b/src/main/webapp/partials/head.jsp new file mode 100644 index 0000000000..e70039f482 --- /dev/null +++ b/src/main/webapp/partials/head.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/27/21 + Time: 4:12 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + $Title$ + + + $END$ + + From 9ea35d34baff592b32bd02d1a0b0c8f934b6e02b Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Fri, 28 May 2021 11:51:45 -0500 Subject: [PATCH 09/16] completed: jstl and jsp exercise --- src/main/java/HelloServlet.java | 21 +++++++++++++ src/main/webapp/hello.jsp | 17 ++++++++++ src/main/webapp/login.jsp | 49 +++++++++++++++++++++++++---- src/main/webapp/partials/body.jsp | 12 +++---- src/main/webapp/partials/footer.jsp | 12 +++---- src/main/webapp/partials/head.jsp | 12 +++---- src/main/webapp/profile.jsp | 16 ++++++---- 7 files changed, 109 insertions(+), 30 deletions(-) create mode 100644 src/main/java/HelloServlet.java create mode 100644 src/main/webapp/hello.jsp diff --git a/src/main/java/HelloServlet.java b/src/main/java/HelloServlet.java new file mode 100644 index 0000000000..9b97c8259c --- /dev/null +++ b/src/main/java/HelloServlet.java @@ -0,0 +1,21 @@ +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@WebServlet(name = "HelloServlet ",urlPatterns = "/helloLecture") +public class HelloServlet extends HttpServlet { + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String name = request.getParameter("name"); + + if(name == null){ + name = "World"; + }else if(name .equalsIgnoreCase("kelvon")){ + name = "Mr.Patterson"; + } + request.setAttribute("viewName", name); + request.getRequestDispatcher("/hello.jsp").forward(request,response); + } +} diff --git a/src/main/webapp/hello.jsp b/src/main/webapp/hello.jsp new file mode 100644 index 0000000000..0c3da50400 --- /dev/null +++ b/src/main/webapp/hello.jsp @@ -0,0 +1,17 @@ + +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/28/21 + Time: 11:28 AM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Hello JSP + + +

    Hello there, ${viewName}!

    + + diff --git a/src/main/webapp/login.jsp b/src/main/webapp/login.jsp index d93cfd49c9..d1273123f4 100644 --- a/src/main/webapp/login.jsp +++ b/src/main/webapp/login.jsp @@ -6,11 +6,48 @@ To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - $Title$ - - - $END$ - + + Login + + +

    Log In

    +<% + request.getParameter("username"); + request.getParameter("password"); +%> +

    + ${param.username} +

    +

    + ${param.password} +

    + + +

    Hello Admin, please login

    +
    + + + + +

    Sorry you're not an admin!

    +
    +
    +
    +
    + + +
    +
    + + +
    +
    + + + + +
    + diff --git a/src/main/webapp/partials/body.jsp b/src/main/webapp/partials/body.jsp index e70039f482..f8963c452f 100644 --- a/src/main/webapp/partials/body.jsp +++ b/src/main/webapp/partials/body.jsp @@ -7,10 +7,10 @@ --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> - - $Title$ - - - $END$ - + + Body + + + + diff --git a/src/main/webapp/partials/footer.jsp b/src/main/webapp/partials/footer.jsp index de36cdddb9..b8ddf152dc 100644 --- a/src/main/webapp/partials/footer.jsp +++ b/src/main/webapp/partials/footer.jsp @@ -7,10 +7,10 @@ --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> - - $Title$ - - - $END$ - + + Title + + + + diff --git a/src/main/webapp/partials/head.jsp b/src/main/webapp/partials/head.jsp index e70039f482..e2dff1d48e 100644 --- a/src/main/webapp/partials/head.jsp +++ b/src/main/webapp/partials/head.jsp @@ -7,10 +7,10 @@ --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> - - $Title$ - - - $END$ - + + Head + + + + diff --git a/src/main/webapp/profile.jsp b/src/main/webapp/profile.jsp index d93cfd49c9..774653ace8 100644 --- a/src/main/webapp/profile.jsp +++ b/src/main/webapp/profile.jsp @@ -6,11 +6,15 @@ To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ include file="partials/navbar.jsp" %> +<%@ include file="partials/head.jsp" %> +<%@ include file="partials/body.jsp" %> +<%@ include file="partials/footer.jsp" %> - - $Title$ - - - $END$ - + + Profile + + + + From 26f7be87ab08540fa10f0e41154f5f5070e8757a Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Fri, 28 May 2021 15:08:51 -0500 Subject: [PATCH 10/16] feat:Guessing game --- src/main/java/GuessServlet.java | 30 ++++++++++++++++++++++++++ src/main/webapp/partials/correct.jsp | 16 ++++++++++++++ src/main/webapp/partials/guess.jsp | 28 ++++++++++++++++++++++++ src/main/webapp/partials/incorrect.jsp | 17 +++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 src/main/java/GuessServlet.java create mode 100644 src/main/webapp/partials/correct.jsp create mode 100644 src/main/webapp/partials/guess.jsp create mode 100644 src/main/webapp/partials/incorrect.jsp diff --git a/src/main/java/GuessServlet.java b/src/main/java/GuessServlet.java new file mode 100644 index 0000000000..3999e8ceee --- /dev/null +++ b/src/main/java/GuessServlet.java @@ -0,0 +1,30 @@ +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + + +@WebServlet(name="GuessServlet", urlPatterns = "/guess") + +public class GuessServlet extends HttpServlet { +@Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + String guess = request.getParameter("guess"); + int random = (int) Math.floor((Math.random() * 3) + 1); + String randomNumString = Integer.toString(random); + + if(guess.equalsIgnoreCase(randomNumString)){ + response.sendRedirect("/correct.jsp"); + }else if(!guess.equalsIgnoreCase(randomNumString)){ + response.sendRedirect("/incorrect.jsp"); + } + } +@Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.sendRedirect("/guess.jsp"); + + } +} diff --git a/src/main/webapp/partials/correct.jsp b/src/main/webapp/partials/correct.jsp new file mode 100644 index 0000000000..6d379125a6 --- /dev/null +++ b/src/main/webapp/partials/correct.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/28/21 + Time: 2:00 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Maybe it was luck, maybe it wasn't who knows? but you got it right ! + + + + + diff --git a/src/main/webapp/partials/guess.jsp b/src/main/webapp/partials/guess.jsp new file mode 100644 index 0000000000..c086196367 --- /dev/null +++ b/src/main/webapp/partials/guess.jsp @@ -0,0 +1,28 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/28/21 + Time: 12:16 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Guessing Game + + +

    Welcome to the guessing game !!

    +

    In this game you will guess a number between 1 and 3! Please submit your answer below in the text field!

    +
    +
    + + +
    +
    + + + + +
    + + diff --git a/src/main/webapp/partials/incorrect.jsp b/src/main/webapp/partials/incorrect.jsp new file mode 100644 index 0000000000..c0696a6566 --- /dev/null +++ b/src/main/webapp/partials/incorrect.jsp @@ -0,0 +1,17 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/28/21 + Time: 1:58 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Sike! That's the wrong numba!! <br> + -SupaHotFire + + + + + From d4b5a2d4892339b48f08ec9cd05c4129d8d2ef29 Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Tue, 1 Jun 2021 09:12:17 -0500 Subject: [PATCH 11/16] feat: guessGame --- src/main/java/CorrectServlet.java | 24 +++++++++++++++++++++++ src/main/java/GuessServlet.java | 6 ++++-- src/main/java/IncorrectServlet.java | 25 ++++++++++++++++++++++++ src/main/webapp/{partials => }/guess.jsp | 0 src/main/webapp/guessResult.jsp | 16 +++++++++++++++ 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 src/main/java/CorrectServlet.java create mode 100644 src/main/java/IncorrectServlet.java rename src/main/webapp/{partials => }/guess.jsp (100%) create mode 100644 src/main/webapp/guessResult.jsp diff --git a/src/main/java/CorrectServlet.java b/src/main/java/CorrectServlet.java new file mode 100644 index 0000000000..273accd043 --- /dev/null +++ b/src/main/java/CorrectServlet.java @@ -0,0 +1,24 @@ +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + + +@WebServlet(name="CorrectServlet", urlPatterns = "/correct") + +public class CorrectServlet extends HttpServlet { + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + + request.setAttribute("guessResult", "Incorrect!"); + request.getRequestDispatcher("/guessResult.jsp").forward(request, response); + } + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.sendRedirect("/guess.jsp"); + + } +} diff --git a/src/main/java/GuessServlet.java b/src/main/java/GuessServlet.java index 3999e8ceee..fb5593e076 100644 --- a/src/main/java/GuessServlet.java +++ b/src/main/java/GuessServlet.java @@ -17,10 +17,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) String randomNumString = Integer.toString(random); if(guess.equalsIgnoreCase(randomNumString)){ - response.sendRedirect("/correct.jsp"); + response.sendRedirect("/correct"); }else if(!guess.equalsIgnoreCase(randomNumString)){ - response.sendRedirect("/incorrect.jsp"); + response.sendRedirect("/incorrect"); } + request.setAttribute("guessResult", guess); + request.getRequestDispatcher("/guessResult.jsp").forward(request, response); } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { diff --git a/src/main/java/IncorrectServlet.java b/src/main/java/IncorrectServlet.java new file mode 100644 index 0000000000..2fadaf5a66 --- /dev/null +++ b/src/main/java/IncorrectServlet.java @@ -0,0 +1,25 @@ +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + + +@WebServlet(name="IncorrectServlet", urlPatterns = "/incorrect") + +public class IncorrectServlet extends HttpServlet { + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + + request.setAttribute("guessResult", "Incorrect!"); + request.getRequestDispatcher("/guessResult.jsp").forward(request, response); + + } + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.sendRedirect("/guessResult.jsp"); + + } +} diff --git a/src/main/webapp/partials/guess.jsp b/src/main/webapp/guess.jsp similarity index 100% rename from src/main/webapp/partials/guess.jsp rename to src/main/webapp/guess.jsp diff --git a/src/main/webapp/guessResult.jsp b/src/main/webapp/guessResult.jsp new file mode 100644 index 0000000000..59dcadf8c9 --- /dev/null +++ b/src/main/webapp/guessResult.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 5/31/21 + Time: 11:54 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Guess Result + + +

    Your answer is ${guessResult}

    + + From 52f51b6d823fa52992145e44bef39263dec22f2b Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Tue, 1 Jun 2021 10:53:43 -0500 Subject: [PATCH 12/16] feat:mvc lecture --- .../java/MvcLecture/CreateProductServlet.java | 30 ++++++++++++++++++ src/main/java/MvcLecture/CsvProductsDao.java | 4 +++ src/main/java/MvcLecture/DaoFactory.java | 12 +++++++ src/main/java/MvcLecture/ListProductsDao.java | 31 +++++++++++++++++++ src/main/java/MvcLecture/Product.java | 14 +++++++++ src/main/java/MvcLecture/Products.java | 10 ++++++ .../java/MvcLecture/ShowProductsServlet.java | 28 +++++++++++++++++ src/main/webapp/createProduct.jsp | 25 +++++++++++++++ src/main/webapp/productIndex.jsp | 25 +++++++++++++++ 9 files changed, 179 insertions(+) create mode 100644 src/main/java/MvcLecture/CreateProductServlet.java create mode 100644 src/main/java/MvcLecture/CsvProductsDao.java create mode 100644 src/main/java/MvcLecture/DaoFactory.java create mode 100644 src/main/java/MvcLecture/ListProductsDao.java create mode 100644 src/main/java/MvcLecture/Product.java create mode 100644 src/main/java/MvcLecture/Products.java create mode 100644 src/main/java/MvcLecture/ShowProductsServlet.java create mode 100644 src/main/webapp/createProduct.jsp create mode 100644 src/main/webapp/productIndex.jsp diff --git a/src/main/java/MvcLecture/CreateProductServlet.java b/src/main/java/MvcLecture/CreateProductServlet.java new file mode 100644 index 0000000000..f5d706ba30 --- /dev/null +++ b/src/main/java/MvcLecture/CreateProductServlet.java @@ -0,0 +1,30 @@ +package MvcLecture; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@WebServlet(name="CreateProductServlet", urlPatterns = "/products/create") +public class CreateProductServlet extends HttpServlet { + + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + request.getRequestDispatcher("/createProduct.jsp").forward(request, response); + } + + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + Products productsDao = DaoFactory.getProductsDao(); + // create a new product based on the submitted data + String name = request.getParameter("name"); + double price = Double.parseDouble(request.getParameter("price")); + Product product = new Product(name, price); + // persist the new product + productsDao.insert(product); + response.sendRedirect("/products"); + } +} diff --git a/src/main/java/MvcLecture/CsvProductsDao.java b/src/main/java/MvcLecture/CsvProductsDao.java new file mode 100644 index 0000000000..f6bbab3266 --- /dev/null +++ b/src/main/java/MvcLecture/CsvProductsDao.java @@ -0,0 +1,4 @@ +package MvcLecture; + +public class CsvProductsDao { +} diff --git a/src/main/java/MvcLecture/DaoFactory.java b/src/main/java/MvcLecture/DaoFactory.java new file mode 100644 index 0000000000..cf351adda9 --- /dev/null +++ b/src/main/java/MvcLecture/DaoFactory.java @@ -0,0 +1,12 @@ +package MvcLecture; + +public class DaoFactory { + private static Products productsDao; + + public static Products getProductsDao(){ + if(productsDao == null){ + productsDao = new ListProductsDao(); + } + return productsDao; + } +} diff --git a/src/main/java/MvcLecture/ListProductsDao.java b/src/main/java/MvcLecture/ListProductsDao.java new file mode 100644 index 0000000000..d09c6cb159 --- /dev/null +++ b/src/main/java/MvcLecture/ListProductsDao.java @@ -0,0 +1,31 @@ +package MvcLecture; + +import java.util.ArrayList; +import java.util.List; + +public class ListProductsDao implements Products{ + //structure to return all the products + private List products = new ArrayList<>(); + + + // When an instance of this class is created, we'll populate the + // products array list with data, "faking" the records + public ListProductsDao(){ + insert(new Product("hammer", 9.99)); + insert(new Product("screwdriver", 9.99)); + insert(new Product("drill", 19.99)); + } + + @Override //@Override makes sure we are overriding from the super + + public List all() { + return this.products; + } + + @Override //@Override makes sure we are overriding from the super + // Persist a new record. We'll simulate this by adding the passed object + // to our internal array list of products. + public void insert(Product product) { + this.products.add(product); + } +} diff --git a/src/main/java/MvcLecture/Product.java b/src/main/java/MvcLecture/Product.java new file mode 100644 index 0000000000..14be671f6f --- /dev/null +++ b/src/main/java/MvcLecture/Product.java @@ -0,0 +1,14 @@ +package MvcLecture; + +public class Product { + private String name; //fields(informed by the entity + private double price;//fields + + public Product(){ + //empty constructor always necessary + } + public Product(String name, double price){ + this.name = name; + this.price=price; + }//filled constructor +} diff --git a/src/main/java/MvcLecture/Products.java b/src/main/java/MvcLecture/Products.java new file mode 100644 index 0000000000..19f01b69c1 --- /dev/null +++ b/src/main/java/MvcLecture/Products.java @@ -0,0 +1,10 @@ +package MvcLecture; + + +import java.util.List; + +public interface Products { + //here we provide the behaviors/methods // List Data types + List all(); + void insert(Product product); +} diff --git a/src/main/java/MvcLecture/ShowProductsServlet.java b/src/main/java/MvcLecture/ShowProductsServlet.java new file mode 100644 index 0000000000..44651eecb4 --- /dev/null +++ b/src/main/java/MvcLecture/ShowProductsServlet.java @@ -0,0 +1,28 @@ +package MvcLecture; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +@WebServlet(name= "ShowProductServlet", urlPatterns = "/products") +public class ShowProductsServlet extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + //"Hey Servlet go instantiate from that getProductsDao method i set up! == get a DAI object + Products productsDao= DaoFactory.getProductsDao(); + + //Let's go get the products + + List showProducts = productsDao.all(); + + + req.setAttribute("products", showProducts); + req.getRequestDispatcher("/productIndex.jsp").forward(req, res); + // + } +} diff --git a/src/main/webapp/createProduct.jsp b/src/main/webapp/createProduct.jsp new file mode 100644 index 0000000000..e4f8cd5129 --- /dev/null +++ b/src/main/webapp/createProduct.jsp @@ -0,0 +1,25 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 6/1/21 + Time: 10:11 AM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Create A Product + + +

    Create A Product

    +
    + + +
    + + +
    + +
    + + diff --git a/src/main/webapp/productIndex.jsp b/src/main/webapp/productIndex.jsp new file mode 100644 index 0000000000..418bd88433 --- /dev/null +++ b/src/main/webapp/productIndex.jsp @@ -0,0 +1,25 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 6/1/21 + Time: 10:00 AM + To change this template use File | Settings | File Templates. +--%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + View Products + + +

    Here are all the products:

    + + +
    +

    ${product.name}

    +

    Price: $ ${product.price}

    +
    +
    + + + From 798216e06aff4f9914c4d71906cf645b5d77f84a Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Tue, 1 Jun 2021 22:01:22 -0500 Subject: [PATCH 13/16] feat: guessing game --- src/main/java/CorrectServlet.java | 11 +++-------- src/main/java/GuessServlet.java | 7 ++++--- src/main/java/IncorrectServlet.java | 10 ++-------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/main/java/CorrectServlet.java b/src/main/java/CorrectServlet.java index 273accd043..fb8049da12 100644 --- a/src/main/java/CorrectServlet.java +++ b/src/main/java/CorrectServlet.java @@ -9,16 +9,11 @@ @WebServlet(name="CorrectServlet", urlPatterns = "/correct") public class CorrectServlet extends HttpServlet { - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - - request.setAttribute("guessResult", "Incorrect!"); - request.getRequestDispatcher("/guessResult.jsp").forward(request, response); - } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.sendRedirect("/guess.jsp"); + request.setAttribute("guessResult","correct"); + request.getRequestDispatcher("/guessResult.jsp").forward(request, response); + } } diff --git a/src/main/java/GuessServlet.java b/src/main/java/GuessServlet.java index fb5593e076..ddd72ed75d 100644 --- a/src/main/java/GuessServlet.java +++ b/src/main/java/GuessServlet.java @@ -21,12 +21,13 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) }else if(!guess.equalsIgnoreCase(randomNumString)){ response.sendRedirect("/incorrect"); } - request.setAttribute("guessResult", guess); - request.getRequestDispatcher("/guessResult.jsp").forward(request, response); +// request.setAttribute("guessResult", guess); +// request.getRequestDispatcher("/guessResult.jsp").forward(request, response); } + @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.sendRedirect("/guess.jsp"); + request.getRequestDispatcher("/guess.jsp").forward(request, response); } } diff --git a/src/main/java/IncorrectServlet.java b/src/main/java/IncorrectServlet.java index 2fadaf5a66..6b6154f29f 100644 --- a/src/main/java/IncorrectServlet.java +++ b/src/main/java/IncorrectServlet.java @@ -9,17 +9,11 @@ @WebServlet(name="IncorrectServlet", urlPatterns = "/incorrect") public class IncorrectServlet extends HttpServlet { - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - - request.setAttribute("guessResult", "Incorrect!"); - request.getRequestDispatcher("/guessResult.jsp").forward(request, response); - } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.sendRedirect("/guessResult.jsp"); + request.setAttribute("guessResult","incorrect"); + request.getRequestDispatcher("/guessResult.jsp").forward(request, response); } } From 861ed7e7708dbdd18cbb2ccfd02c65868ad817dc Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Tue, 1 Jun 2021 22:07:14 -0500 Subject: [PATCH 14/16] complete: guessing game --- src/main/java/GuessServlet.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/GuessServlet.java b/src/main/java/GuessServlet.java index ddd72ed75d..26c251b3a4 100644 --- a/src/main/java/GuessServlet.java +++ b/src/main/java/GuessServlet.java @@ -29,5 +29,6 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.getRequestDispatcher("/guess.jsp").forward(request, response); + } } From 7df066af599b6af729fe7165d09258b1772c45bb Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Tue, 1 Jun 2021 23:09:49 -0500 Subject: [PATCH 15/16] completed: pizza order --- src/main/java/PizzaOrderServlet.java | 29 ++++++++++++++ src/main/webapp/pizza-order.jsp | 56 ++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 src/main/java/PizzaOrderServlet.java create mode 100644 src/main/webapp/pizza-order.jsp diff --git a/src/main/java/PizzaOrderServlet.java b/src/main/java/PizzaOrderServlet.java new file mode 100644 index 0000000000..02ed6b0b02 --- /dev/null +++ b/src/main/java/PizzaOrderServlet.java @@ -0,0 +1,29 @@ +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@WebServlet(name="PizzaOrderServlet", urlPatterns = "/pizza-order") +public class PizzaOrderServlet extends HttpServlet { + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + req.getRequestDispatcher("/pizza-order.jsp").forward(req,resp); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + System.out.println(req.getParameter("crust")); + System.out.println(req.getParameter("sauce")); + System.out.println(req.getParameter("crust-size")); + System.out.println(req.getParameter("pepperoni")); + System.out.println(req.getParameter("sausage")); + System.out.println(req.getParameter("bacon")); + System.out.println(req.getParameter("onion")); + System.out.println(req.getParameter("mushrooms")); + System.out.println(req.getParameter("pineapple")); + System.out.println(req.getParameter("address")); + req.getRequestDispatcher("/pizza-order.jsp").forward(req,resp); + } +} diff --git a/src/main/webapp/pizza-order.jsp b/src/main/webapp/pizza-order.jsp new file mode 100644 index 0000000000..f4154213b4 --- /dev/null +++ b/src/main/webapp/pizza-order.jsp @@ -0,0 +1,56 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 6/1/21 + Time: 10:22 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Pizza Order + + +
    + + +
    + + +
    + + +
    + +
    + +
    + +
    + +
    + +
    + +
    + + + +
    + +
    + + + From c54372a1b342e93c6011d39e89f5491481522e07 Mon Sep 17 00:00:00 2001 From: Kelvon Patterson Date: Tue, 1 Jun 2021 23:39:04 -0500 Subject: [PATCH 16/16] feat: colorPage complete --- src/main/java/ColorPageServlet.java | 20 ++++++++++++++++++++ src/main/java/ViewColorServlet.java | 20 ++++++++++++++++++++ src/main/webapp/pickcolor.jsp | 21 +++++++++++++++++++++ src/main/webapp/viewcolor.jsp | 17 +++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 src/main/java/ColorPageServlet.java create mode 100644 src/main/java/ViewColorServlet.java create mode 100644 src/main/webapp/pickcolor.jsp create mode 100644 src/main/webapp/viewcolor.jsp diff --git a/src/main/java/ColorPageServlet.java b/src/main/java/ColorPageServlet.java new file mode 100644 index 0000000000..a2bbdb9b84 --- /dev/null +++ b/src/main/java/ColorPageServlet.java @@ -0,0 +1,20 @@ +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@WebServlet(name="ColorPageServlet", urlPatterns = "/pickcolor") +public class ColorPageServlet extends HttpServlet { + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + req.getRequestDispatcher("/pickcolor.jsp").forward(req,resp); + } + +// @Override +// protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { +// req.getParameter("pickColor"); +// req.getRequestDispatcher("/viewcolor.jsp").forward(req,resp); +// } +} diff --git a/src/main/java/ViewColorServlet.java b/src/main/java/ViewColorServlet.java new file mode 100644 index 0000000000..5282572e91 --- /dev/null +++ b/src/main/java/ViewColorServlet.java @@ -0,0 +1,20 @@ +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@WebServlet(name="ViewColorServlet", urlPatterns = "/viewcolor") +public class ViewColorServlet extends HttpServlet { +// @Override +// protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { +// req.getRequestDispatcher("/viewcolor.jsp").forward(req,resp); +// } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + req.setAttribute("pickColor",req.getParameter("pickColor")); + req.getRequestDispatcher("/viewcolor.jsp").forward(req,resp); + } +} diff --git a/src/main/webapp/pickcolor.jsp b/src/main/webapp/pickcolor.jsp new file mode 100644 index 0000000000..0aa1235d99 --- /dev/null +++ b/src/main/webapp/pickcolor.jsp @@ -0,0 +1,21 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 6/1/21 + Time: 11:13 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Pick Color + + +

    Choose a color to turn your page to!

    +
    + + + +
    + + diff --git a/src/main/webapp/viewcolor.jsp b/src/main/webapp/viewcolor.jsp new file mode 100644 index 0000000000..7dd23fe4cd --- /dev/null +++ b/src/main/webapp/viewcolor.jsp @@ -0,0 +1,17 @@ +<%-- + Created by IntelliJ IDEA. + User: Kelvon + Date: 6/1/21 + Time: 11:13 PM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + View Color + + + + + +