Sunday 5 July 2020

JAVA Google Calendar API | Part 2 | Display All Events On Browser Using JSP Framework



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 :)
------------------------------------------------


Google Calendar Java Part 1 :-
https://youtu.be/zPsSUEGDfVY

Google Calendar Java Part 1. 5:-
https://youtu.be/0daf87wjLs4

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 part 2 of Google Calendar connection with JAVA, we are going to display events from beginning & display them on web browser using JSP framework.
There are two parts that I have made. Links are given in the description. 1st part is mandatory which shows how to connect java with google calendar and display events in terminal.
The second part, which is actually 1.5, is the tutorial on how to create JSP Project using Gradle.
The reason why it is mentioned as 1.5 and not 2 is because it is a separate topic on its own.

And in this part, we are going to merge whatever we made in 1 & 1.5, which reduces redundant steps and also makes this video short.

Form part 1 & 1.5, those two folders were created.

From 1st, we first get all available events by making small changes in code.
As you can see, no future events are available.

Go to our java file, and just add zero in DateTime constructor and that is it.
Now if you re-execute, you will get result starting from first event.
You can make changes in setMaxResults function value to change maximum count of results.

Now from part 1.5, which has JSP enabled, we shall copy some files and folders from part 1.
So go inside Connection folder, go inside  src-> main, copy JAVA and RESOURCES folder and go to JSP, paste them in src -> main folder.
Now, again go to connection folder and copy tokens folder, and paste it in JSP where the build.gradle file is.

Now the copy-pasting is done, now go to connection folder, and open build.gradle file in text-editor, in my case, the sublime text.

Now go to JSP and also open it’s build.gradle in text editor.

We have to cut-paste the Calendar JAVA file inside ORG folder to access package.

Now we have to copy-paste the build gradle requirements from connection’s gradle to JSP’s gradle.
First, for the plugin, use JSP gralde’s syntax.
Then copy-paste that whole paragraph.

Copy-paste the function.

Copy paste the libraries and commands.

Now we are going to run to make sure that build.gradle is correct or not.
Run that IP address in browser’s URL.
It is working.

Now, open servlet in text editor at where we are going to call calendar class.
Notice that we move this quickstart file inside org folder, open that in text editor.

Because it is inside ORG folder, name the package as ORG.
Also notice that servlet has the package called org.gradle.demo which denotes the servet file is inside which folder.

Now import that org package to access CalendarQuickstart.java file.

In CalendarQuickstart file, rename the function from main to getEvents, you can use any new name and return type as string.
What we are going to do is to convert events into string and return them to display them in Servlet.
Make sure to return that string at the ending of function.
Now call that class inside servlet, and create and instance, in my case CQ.
I forgot to append string here.
Notice that the function throws Exception, so we have to call that function in try-catch block.
Copy the output link and call that function.
Lets go to terminal, close previously executed gradle using CTRL+C, and execute the command again.
Now if we click on hello, we shall see all the events.

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


1 comment: