function demo(request,response){
request.getScheme() is returning http instead of returning https.
System.out.println(\"\"+request.getScheme());
}
See the answer https://stackoverflow.com/a/19599143/1524502, and note the issues about being behind a reverse proxy or load balancer. Most likely, that is your problem.
The answerer in that question recommended using
request.getHeader("x-forwarded-proto")
instead, though that is dependent on your load balancer setting the header correctly.