Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/eugenp/tutorials into BAE…
Browse files Browse the repository at this point in the history
…L-10982
  • Loading branch information
amit2103 committed Mar 17, 2019
2 parents 70736ee + b7c1092 commit 92809e9
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core-kotlin-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

- [Void Type in Kotlin](https://www.baeldung.com/kotlin-void-type)
- [How to use Kotlin Range Expressions](https://www.baeldung.com/kotlin-ranges)
- [Split a List into Parts in Kotlin](https://www.baeldung.com/kotlin-split-list-into-parts)

3 changes: 3 additions & 0 deletions java-streams-2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Relevant Articles:
- [Guide to Stream.reduce()](https://www.baeldung.com/java-stream-reduce)

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.baeldung.filters;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter(urlPatterns = "/uppercase")
public class EmptyParamFilter implements Filter {

@Override
public void init(FilterConfig filterConfig) throws ServletException {
}

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain filterChain) throws IOException, ServletException {
String inputString = servletRequest.getParameter("input");

if (inputString != null && inputString.matches("[A-Za-z0-9]+")) {
filterChain.doFilter(servletRequest, servletResponse);
} else {
servletResponse.getWriter().println("Missing input parameter");
}
}

@Override
public void destroy() {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.baeldung.listeners;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class AppListener implements ServletContextListener {

@Override
public void contextInitialized(ServletContextEvent event) {
ServletContext context = event.getServletContext();
context.setAttribute("counter", 0);
}

@Override
public void contextDestroyed(ServletContextEvent event) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.baeldung.listeners;

import javax.servlet.ServletContext;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpServletRequest;

@WebListener
public class RequestListener implements ServletRequestListener {

@Override
public void requestInitialized(ServletRequestEvent event) {
}

@Override
public void requestDestroyed(ServletRequestEvent event) {
HttpServletRequest request = (HttpServletRequest)event.getServletRequest();
if (!request.getServletPath().equals("/counter")) {
ServletContext context = event.getServletContext();
context.setAttribute("counter", (int)context.getAttribute("counter") + 1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.baeldung.servlets;

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.io.PrintWriter;

@WebServlet(urlPatterns = "/counter", name = "counterServlet")
public class CounterServlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();

int count = (int)request.getServletContext().getAttribute("counter");

out.println("Request counter: " + count);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.baeldung.servlets;

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.io.PrintWriter;

@WebServlet(urlPatterns = "/uppercase", name = "uppercaseServlet")
public class UppercaseServlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
String inputString = request.getParameter("input").toUpperCase();

PrintWriter out = response.getWriter();

out.println(inputString);
}
}
1 change: 1 addition & 0 deletions persistence-modules/spring-boot-persistence/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
- [Hibernate Field Naming with Spring Boot](https://www.baeldung.com/hibernate-field-naming-spring-boot)
- [Integrating Spring Boot with HSQLDB](https://www.baeldung.com/spring-boot-hsqldb)
- [Configuring a DataSource Programmatically in Spring Boot](https://www.baeldung.com/spring-boot-configure-data-source-programmatic)
- [Resolving “Failed to Configure a DataSource” Error](https://www.baeldung.com/spring-boot-failed-to-configure-data-source)
3 changes: 3 additions & 0 deletions spring-boot-angular/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Relevant Articles:
- [Building a Web Application with Spring Boot and Angular](https://www.baeldung.com/spring-boot-angular-web)

0 comments on commit 92809e9

Please sign in to comment.