Home » Java (page 20)

Java

JDK 12 Switch Expression Encountering Unanticipated Enum Value

As I wrote about in my post “Playing with JDK 12’s Switch Expressions“, the JDK 12 Early Access Builds have made it easy to experiment with the implementation of JEP 325 [“Switch Expressions (Preview)”]. My post “JDK 12: Switch Statements/Expressions in Action” used code examples to demonstrate core features and characteristics of the enhanced switch statement and the new switch ...

Read More »

JDK 12: Switch Statements/Expressions in Action

My last post “Playing with JDK 12’s Switch Expressions” talked about use of the JDK 12 Early Access Builds to try out JEP 325 switch expressions and statements and provided a simple example. This post uses the same JDK 12 Early Access Build 10 to demonstrate different features of switch expressions and enhanced switch statements. I used a 2×2 grid ...

Read More »

Ajax File Upload with Servlet and Bootstrap

java-interview-questions-answers

Introduction In this tutorial, we will check how Ajax file upload works with Servlets. Also we will decorate our form with Bootstrap and ajaxify file upload through jQuery Ajax. Implementation The basic servlet implementation is the same. So the first thing we need to do is update our web.xml file and specify servlets for our application. web.xml <?xml version="1.0" encoding="UTF-8"?> ...

Read More »

Containerising a Spring Data Cassandra application

I’m continuing my journey of learning Docker. I am still keeping it simple at this point. This time around, I am going to tackle converting a Spring and Cassandra application to use containers instead of running locally on the host machine. More precisely, using Spring Data Cassandra to sort out the application. I wish I looked at doing this change ...

Read More »

Java: Mocking a ResultSet using Mockito

This post shows how you can mock a java.sql.ResultSet using Mockito. It can be used to help unit test code which performs operations on ResultSets (such as a ResultSetExtractor) without relying on an external datasource. You can create a MockResultSet by providing a list of column names and a 2D array of data. For example: var rs = MockResultSet.create( new ...

Read More »

Playing with JDK 12’s Switch Expressions

In the blog post “JDK Language Feature Preview in Action: Switch Expressions,” I discussed how JEP 325 [“Switch Expressions (Preview)”] is an early application of a designated “preview language feature” as spelled out by JEP 12 [“Preview Language and VM Features”]. JEP 325 is targeted for JDK 12. Even better, the Early Access Builds for JDK 12 already provide support ...

Read More »

TIP: Activate via URL and Send Arguments

spring-interview-questions-answers

The most secure password in the world is the one that doesn’t exist. You remove the user from the equation with a completely random key. To be fair this has some drawbacks and a password still exists somewhere (in your phone/email) but generally this works rather well…​ The trick is simple, if we want to authenticate a user we can ...

Read More »