Tuesday, December 31, 2019

Java Servlet Session Timeout and Examples

1. Overview


In this tutorial, how to set up and configure a session timeout in a java Servlet based web application.

Configure Session Timeout in the web.xml of a Java Servlet web application, and globally for a Tomcat or Jetty Server.

This can be done in many ways as follows.

A) web.xml
B) Programmatically
C) Tomcat or any server configuration


Java Servlet Session Timeout


Monday, December 30, 2019

Java 8 Method References With Examples

1. Overview


In this tutorial, We'll learn how to use Method References in Java 8 and where we can use Method References in the programs. To understand this article, you should have a minimal understanding of Lambda Expressions.

Read: Introduction to Lambda Expressions in Java 8

Method References are part of the new Java 8 concept and used to refer to the functional method of Functional Interface. Syntax is ClassName::methodName. Method ref is indicated with "::" - double colon operator. This is a compact and simple form of the lambda expression. If you are using a lambda expression to refer only functional method and not any additional logic then it is best to use method references in these kinds of scenarios.

We'll learn types of method references and their example programs.

Java 8 Method References With Examples


Sunday, December 29, 2019

Java 8 Stream mapToInt(ToIntFunction) Method Examples | Convert Stream to IntStream

1. Overview


In this java 8 Streams series, We'll learn today what is Stream API mapToInt() method and when to use this. This method is used to convert the Stream to IntStream. Let us see it's syntax and few examples on mapToInt() method. This is also part of intermediate operations such as map() and filter() methods.

Java 8 Stream mapToInt(ToIntFunction) Method Examples | Convert Stream to IntStream




Saturday, December 28, 2019

Java List or Traverse All Files in Folder Recursively (Java 8 Files.walk() Example)

1. Overview


In this programming tutorial, we are showing an example program on how to list or traverse all files and folders including subfolders in a directory using the following methods.

A) Using the classic approach
B) Using Java 8 methods

Traverse All Files in Folder Recursively


Java 12 Files mismatch Method Example to Compare two Files