Sunday 14 June 2020

Gradle JSP Quick Setup Tutorial | JAVA & Groovy Language | Web Application



Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------

Official Gradle JSP Guidelines:-
https://guides.gradle.org/building-java-web-applications/

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
In this video, I shall create JSP application using gradle in the quickest way possible.
There are plenty of tutorials available on internet for installing gradle and java, so we shall skip that part.
There is an official document from gradle to setup JSP. That link is given in the description.
There are requirements that you should have.

Configuring basic JSP doesn’t require more than 5 minutes.
And we are using groovy as a build.

First instruction is to create folder structure like this.
Open the file system or my computer, I already created a TUTORIAL folder, go inside it and start to create new folders.

Now come to home folder, which is webdemo, and create a new file “build.gradle”.

Click on GROOVY tab if kotlin is selected by default.

Next, open webdemo folder in terminal or command prompt.

Even though the gradle version is greater than 4.10, don’t use that wrapper.

type the same command as they provided.

It will create some files and folders inside webdemo.

Now, create more folder as they told you, and create HelloServlet.java file inside that folder.

There are the number which indicates what is the purpose of that code.

Now come back to webapp folder and create two new files, index.html and response.jsp.

Copy paste the code in index.html.

copy paste the code in response.jsp.

Now, copy this id and paste it in plug in.

After that, go to terminal and type the command they provided.

It will provide a URL. Copy that and paste it in browser.

If you click on hello, the GET method is called.

Force refresh it.

To access JSP, type name and click on button.

So, that is it. The core JSP is ready.

Required links are given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching. 


Monday 8 June 2020

Java Google Calendar API | Linux Terminal & Gradle Groovy | Display Events | Fix redirect_uri_mismatch



You can download library from:- https://unpossiblepog.com/research-and-development/GRADLE+JAVA/Google-Gradle-API-In-Java-For-Google-Drive-And-Google-Calendar

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------

Official Google Developer page for google calendar JAVA API:-
https://developers.google.com/calendar/quickstart/java

Google Console  page:-
https://console.cloud.google.com/

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
In this video, I shall make a connection between Google calendar and JAVA using gradle and display events in terminal or Command prompt.

Following operation requires Linux as it provides more flexibility for performing tasks.

Output can later be used in any framework like Spring, JSP, hibernate etc.

Lets go to google and search “google calendar quickstart java” go to developers.google.com link.

Requirements :
1. Google account with google calendar enabled.
2. Linux OS (debian family). I am using LUBUNTU. install linux in vmware or virtualbox if you don’t have LINUX as BOOT OS.
3. JAVA JDK version 1.8 or grater.
4. Then, gradle version greater than or equals to 2.3.



For people who doesn’t know what is gradle, in simple words, it is a build-tool which has 2 types, Groovy and Kotlin. And both of them can use any language Syntax for its script.
Kotlin is mostly used for android development and has file extension of .gradle.kts but groovy is mostly is used for webserver and with extension .gradle.

We are going to use groovy build and JAVA.

Then lets go to calendar.google.com and create an event. The red line is the current time so make the event after that line.

Now open file system. Create a folder in home with any name in my case “GoogleCalendar”.
Open that folder in terminal.

I already installed Java and gradle but still, show you the commands to install them.
Sometimes, you get older version of gradle, so you can upgrade it by using this command.
Then click on enable Google Calender API button.
Select Web server, now, type same url as I showed you. make sure that C in callback is capital.
Click on CREATE.
Download configuration.
Remember that file can be renamed if same file name already exists.

Now, in our newly created folder, create another folder with name CALLBACK. C capital.
Now in terminal, go inside callback folder using cd command.

Check if you have installed java and gradle correctly with required version.

Now, type the command they provided.

Type 1. To select Groovy.
For second question, don’t type anything, press enter directly.

Now if you check folder, some folders & files were automatically created.

Now paste the second command, which will create more folder in your project.

As per instructions, copy-paste credentials.json file from downloaded folder to this path.

Make sure to rename as credentials.json if name is different.

Next instruction is to copy-paste the gradle code in build.gradle file.

After that we have to create a java file at location as they told us.

Paste the code in it.

Here, remove “_READONLY” if you also want to change calendar events in future.

Now lets run the command “gradle run”.

It shall directly open the link in browser, but there is an error called “redirect_uri_mismatch”.

So to solve that, first cancel process by pressing ctrl+c in terminal.

Go to google console.

Left-top-menu, APIs & Services, and select credentials.

As you can see, the top Client Id is what we created on 7th of june, click on it, add URI, make sure to make same configuration as I do.

If you see in java code, the port number is 8888. So change that port in configuration.

Also, go to main callback folder and inside tokens folder, delete the file.
Lets clear the terminal and rerun the command.
It automatically opens the link in browser and you can see this page.
Select your google account,  click on advanced, go to quickstart unsafe, Allow.

You will see this message.
Now if you see it in terminal, you will see the upcoming event that we created at the beginning.
Lets rename it to verify. You can also create multiple events that will not be a problem for program to execute.

Now you can close terminal, and rename the folder.
Now open the renamed folder in terminal with same command and there will not be any problem in future.

In next tutorial, I shall show you how to get all events and display them on browser using JSP framework through gradle.

Required links are given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching. 


Monday 1 June 2020

JAVA Tutorial | Easiest Way To Get List Of Dates Between Two Dates






Code :-


import java.text.SimpleDateFormat;
import java.util.*;

public class DateList {
   
    public static void main(String[] args) throws Exception {
        String from="2020-01-01";
        String to="2020-05-30";
       
        Date d_from = new SimpleDateFormat("yyyy-MM-dd").parse(from);
        Date d_to = new SimpleDateFormat("yyyy-MM-dd").parse(to);
       
        //System.out.println(d_from.getTime());
       
        long t1=d_from.getTime();
        long t2=d_to.getTime();
       
        SimpleDateFormat f=new SimpleDateFormat("yyyy-MM-dd");
       
        if(t1<t2)
        {
            //1 = 1000
            for(long i=t1;i<=t2;i+=86400000)
            {
                System.out.println(f.format(i));
            }
        }
       
    }
   
}


------------------------------------------------
Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------


Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
In this video, I shall show you the easiest way to get list of dates between two dates in JAVA.
Here I am using netbeans IDE and the date format as year-month and date.

 I shall be converting string to date by using date and SimpleDateFormat classes.
With netbeans, you will be assisted to import required packages and handle exceptions.

However, I shall manually handle exception by throwing it in main function line.
Main strategy is to convert date into milliseconds.

Now using LONG as data type is important because the milliseconds are large numbers.
First thing I shall do is to verify if from-date is lesser than to-date by applying if statement.

Now, I shall use for loop, a variable start with from-date and stop at to-date.
In for loop, I shall add 1 day in milliseconds.
One day is 86400 second.
However, 1 second equals to 1000 milliseconds, so add more three zeros.

Let check the output.

Now, the only thing left is to convert milliseconds to date.
For that, SimpleDateFormat variable is required.
Use format function with 1 argument of milliseconds.

The JAVA code handles even a leap as you can see, 29 days in February. 2020 which is the worst year.

The code link is given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching.