diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index 996a7d96b1..783e29f2f2 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -15,4 +15,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [A Quick Guide to Spring MVC Matrix Variables](http://www.baeldung.com/spring-mvc-matrix-variables) - [Intro to WebSockets with Spring](http://www.baeldung.com/websockets-spring) - [File Upload with Spring MVC](http://www.baeldung.com/spring-file-upload) -- [Spring MVC Content Negotiation](http://www.baeldung.com/spring-mvc-content-negotiation-json-xml) +- [Spring MVC Content Negotiation](http://www.baeldung.com/spring-mvc-content-negotiation-json-xml) \ No newline at end of file diff --git a/spring-mvc-java/src/test/README.md b/spring-mvc-java/src/test/README.md index 20ee1918af..260bbdca97 100644 --- a/spring-mvc-java/src/test/README.md +++ b/spring-mvc-java/src/test/README.md @@ -1,2 +1,3 @@ ### Relevant Articles: - [Circular Dependencies in Spring](http://www.baeldung.com/circular-dependencies-in-spring) +- [Guide to JSP](http://www.baeldung.com/guide-to-jsp) \ No newline at end of file diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index e96a8d0392..097353c88c 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -13,3 +13,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Basic Forms with Spring MVC](http://www.baeldung.com/spring-mvc-form-tutorial) - [Returning Image/Media Data with Spring MVC](http://www.baeldung.com/spring-mvc-image-media-data) - [Geolocation by IP in Java](http://www.baeldung.com/geolocation-by-ip-with-maxmind) +- [Guide to JSP](http://www.baeldung.com/guide-to-jsp) \ No newline at end of file diff --git a/spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleOne.java b/spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleOne.java new file mode 100644 index 0000000000..0b153bf8ec --- /dev/null +++ b/spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleOne.java @@ -0,0 +1,31 @@ +package com.baeldung.jsp; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class ExampleOne extends HttpServlet { + + private static final long serialVersionUID = 1L; + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/html"); + PrintWriter out = response.getWriter(); + out.println( + "" + + "
" + + "" + + "This page was rendered by the ExampleOne Servlet!
" + + "" + + "" + ); + } +} \ No newline at end of file diff --git a/spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleThree.java b/spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleThree.java new file mode 100644 index 0000000000..49fefcffde --- /dev/null +++ b/spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleThree.java @@ -0,0 +1,24 @@ +package com.baeldung.jsp; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet( + name = "ExampleThree", + description = "JSP Servlet With Annotations", + urlPatterns = {"/ExampleThree"} +) +public class ExampleThree extends HttpServlet { + private static final long serialVersionUID = 1L; + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String message = request.getParameter("message"); + request.setAttribute("text", message); + request.getRequestDispatcher("/jsp/ExampleThree.jsp").forward(request, response); + } +} diff --git a/spring-mvc-xml/src/main/resources/contentManagementWebMvcConfig.xml b/spring-mvc-xml/src/main/resources/contentManagementWebMvcConfig.xml index e68c88d19d..41422d8954 100644 --- a/spring-mvc-xml/src/main/resources/contentManagementWebMvcConfig.xml +++ b/spring-mvc-xml/src/main/resources/contentManagementWebMvcConfig.xml @@ -11,7 +11,7 @@ http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">You said: ${text}
+ +