Servlets made easy. Write once and run everywhere

Preview:

Citation preview

Let’s serve your dataFrank van der Linden

About me• Freelance Java and front end developer

• Owner of Elstar IT

• Try to do some running and mountain biking

2

Roadmap• Theory

• Prepare

• Set up

• Develop

• Test

• Deploy

3

Theory

What is a servlet• Java program to extends the capabilities of a server

• Servlets provide a component-based, platform-independent method for building Web-based applications

• Servlets run in web containers, Servlet containers

5

Structure and architecture

6

Lifecycle

7

XAgent - a sort of servlet

8

Servlet in NSF• excellent series of Eric McCormick

• https://edm00se.io/servlet-series/

9

Servlet as OSGi plugin• run server wide

• Code can be shared with other processes like DOTS, XPages.

• With small changes, it run also on other Java servers, like Tomcat, WildFly(a.k.a. Boss) and Websphere

10

OSGi architecture

11

Prepare

Prepare• Download IDE e.g. Eclipse JEE

• Set Target platform

• Install PDE Debug plugin

• Create com.ibm.notes.java.api project

13

*See Appendix A for steps to prepare your IDE

Develop

goals• Create a Shared code plugin

• Create a web app plugin which runs on a Java server

• Create a OSGi servlet which run on a Domino server

15

* See Appendix B for setup projects

my goals

16

Shared plugin

17

Domino - Servlet

18

Web app - Servlet

19

show some code

Logging• Build in via java.util.logging.Logger

• Log an error to the console….

21

Logging• ….log to a file, by adding a (File) handler

22

Test

Test

24

Test

25

Test

26

Test

• tell http quit

• load http

27

Warning• After testing remove the pre.launch.ini from your workspace

directory of the Domino server

28

Deploy

Deploy• 2 ways of deployment to Domino

• as deployable jar

• as an update site.

• Add to web server

30

As deployable jar• Export as deployable plugin…

• Put the jar in the correct directory on the server

• tell http quit —> load http

31

As update site• Create Feature project, add plugin projects

• Create Update site project, add Feature project

• Add update site to update site database

• tell http quit —> load http

32

Deploy to web app

33

let’s deploy it

35

Thank you

36

https://bitbucket.org/flinden68/lets-serve-your-data

Appendix A

Target platform

38

Target platform

39

Target platform

40

PDE plugin

41

PDE plugin

42

PDE plugin

43

com.ibm.notes.java.api

44

Appendix B

OSGi Plugin set up

46

OSGi Plugin set up (servlet)

47

OSGi Plugin set up (servlet)

48

OSGi Plugin set up (servlet)

49

Web app set up

50

Recommended