Integrating RPG and Java Server Pages - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Integrating RPG and Java Server Pages

Description:

... that works in tandem with HTML code, separating the page logic from the ... The Service Program must reside within the library list. ... – PowerPoint PPT presentation

Number of Views:66
Avg rating:3.0/5.0
Slides: 18
Provided by: 660
Category:
Tags: rpg | basic | code | codes | com | html | integrating | java | list | of | pages | server

less

Transcript and Presenter's Notes

Title: Integrating RPG and Java Server Pages


1
Welcome
Gulf Coast Midrange Users Group
Topic
Integrating RPG and Java Server Pages
2
Gulf Coast Midrange Users Group
Problem Web Development for AS/400-RPG shops
unaccustomed to Java or other web
development languages.
Welcome to Integrating RPG and Java Server Pages
3
Java Server Pages Definition
JavaServer Pages. A server-side technology,
JavaServer pages are an extension to the Java
servlet technology that was developed by Sun.
JSPs have dynamic scripting capability that works
in tandem with HTML code, separating the page
logic from the static elements -- the actual
design and display of the page. Embedded in the
HTML page, the Java source code and its
extensions help make the HTML more functional,
being used in dynamic database queries, for
example. JSPs are not restricted to any specific
platform or server.
4
Java Server Pages Requirements
  • Java Server Pages require the
  • Tomcat Jsp Container.

5
Jsp Example
ltjspuseBean id"LI" class"meatOrder.LoginMain"
scope"request"gt
ltrtnCd LI.Login()gt ltif ((rtnCd.equals("1"))
) gt ltjspforward
page"Welcome.html"gtlt/jspforwardgt
lt lt

else
gt

ltHTMLgt
ltHEADgt

ltTITLEgtLogin.jsplt/TITLEgt
lt/HEADgt

ltBODYgt
ltH2
align"center"gtAutry Greer and Son's, Inc.lt/H2gt
ltFORM method"post"
name"LogIn"
action"http//S1041402/app1/jsp/Login.jsp
"gt ltp
align"center"gtUser Id ltINPUT type"text"
name"userId" size"10"gtlt/pgt ltp
align"center"gtPassword ltINPUT type"password"
name"passWord" size"10"gtlt/pgt

ltp align"center"gtltINPUT type"submit"
name"logIn" value"Submit"gtlt/pgt ltINPUT
type"hidden" name"rtncd" valuenullgtlt/FORMgt
lt/BODYgt
lt/HTMLgt lt

gt

Jsp to use java class LoginMain And refer to
program as LI
If rtnCd equals 1 forward user to Welcome
page Else Redisplay Login Page
6
Java Objects (Classes, Methods, Variables)
public class LoginMain Program Variables
/ public String userId "
" public String passWord "
" public String rtnCd "0" / Login
native method / public native String
Login() / Getter methods generated by
Websphere / / Return User Id / public
byte getUserId() return
userId.getBytes() / Return
PassWord / public byte getPassWord()
return passWord.getBytes()
Java program example contains 1 java class
(LoginMain) 3 variables(userId, passWord,
rtnCd) 3 methods(Login, getUserId, getPassWord)
Note that method Login does not contan any
code and has the native modifier While
getUserId and getPassword contain code and are
not native
7
The Java Native Interface
The Java Native Interface (JNI) The JNI allows
Java code that runs within a Java Virtual Machine
(JVM) to operate with applications and libraries
written in other languages, such as C, C,Visual
Basic and RPG ILE. In addition, the Invocation
API allows you to embed the Java Virtual Machine
into your native applications. AS/400 Native
RPGILE methods must be coded within Sub-Procedure
Modules and made into Service Programs. The
Service Program must reside within the library
list.
8
Calling AS/400 Java Native Method Requirements
/ Find Login Service Program / static
System.loadLibrary("SRVLOGIN") /
Login native method / public native
String Login()
Find Service Program SRVLOGIN in library list
Call to native method Login
9
Jsp calling native RPG method/sub-procedure
ltjspuseBean id"LI" class"meatOrder.LoginMain"
scope"request"gt
ltrtnCd LI.Login()gt ltif ((rtnCd.equals("1")
)) gt ltjspforward
page"Welcome.html"gtlt/jspforwardgt
/ Login native method / public native
String Login() 3500
Prototyped Native Java Method Login


3700 DLogin
PR O Class(JAVAStringClass)

3800 D
ExtProc(JAVA
3900 D
LM

4000 D
LI)
4100
PLogin B Export

4200 DLogin PI
O Class(JAVAStringClass)

JSP calls Java method Login
A
B
Java calls Native Method Login Found in Service
Program Srvlogin
C
Login Returns string Object rtnCd back to Java
program then to JSP
10
RPG and JNI ProtoTyping of getter method
/ Return User Id / public byte
getUserId() return userId.getBytes()

DGUI
C 'getUserId'
DLM C
'meatOrder.LoginMain'
DLI C
'Login'
Prototyped Java getUserId Method
B
DgetUserId PR 10A
D
ExtProc(JAVA D
LM D
GUI)
DuserId S Like(GetUserId)
C Eval UserId
getUserId(This)

When the getUserId method is called in RPG it
uses the Java method proto-typed
C
B
A
11
Visual Representation of Interaction
A
B
Java Method is a native method. Calls RPG
Sub-Procedure
ltrtnCd LI.Login()gt Jsp makes call to
Java program method
C
D
RPG Sub-Procedure performs all business logic.
Accesses database and returns status code to java
program and JSP

ltif ((rtnCd.equals("1"))) gt ltjspforward
page"Welcome.html"gtlt/jspforwardgt lt
Jsp reacts to rtncd from RPG
12
JSP and RPG Integration Review
Java Native Interface (JNI) provides method of
interfacing JSP's and RPG
RPG can access JSP forms thru prototyped
getter/setter methods
NOTE
Custom Tag Libs can improve development time
often eliminating coding
Two Main JSP Development FrameWorks Struts
Java Server Faces
13
Java Server Faces Example
login.jsp lt_at_ taglib uri"http//java.sun.com/
jsf/html" prefix"h" gt lt_at_ taglib
uri"http//java.sun.com/jsf/core" prefix"f" gt
ltfloadBundle basename"bundle.Messages"
var"Message" /gt lthtmlgt ltheadgtlttitlegtLoginlt/t
itlegtlt/headgt ltbodygt ltfviewgt
lthform id"loginForm" gt
lthmessage for"loginForm" /gtltbr /gt
lthoutputText value"Message.username_l
abel" /gt lthinputText
id"username" value"LoginMain.userName"
required"true" gt
ltfvalidateLength maximum"15" minimum"3" /gt
lt/hinputTextgt
lthmessage for"username" /gtltbr /gt
lthoutputText value"Message.password_la
bel" /gt lthinputSecret
id"password" value"LoginMain.passWord"
required"true" gt
ltfvalidateLength maximum"15" minimum"3" /gt
lt/hinputSecretgt
lthmessage for"password" /gtltbr /gt
lthcommandButton id"submit"
action"LoginMain.login" value"Message.login
_button" /gt lt/hformgt
lt/fviewgt lt/ body gt lt/ html gt
14
Java Server Faces and RPG Interaction
lthcommandButton id"submit" action"LoginMain.L
ogin" value"Message.login_button" /gt
/ Login native method / public
native String Login()
3500 Prototyped Native Java Method Login


3700
DLogin PR O
Class(JAVAStringClass)
3800 D
ExtProc(JAVA

3900 D
LM
4000 D
LI)

4100 PLogin B
Export
4200 DLogin
PI O Class(JAVAStringC
lass)
JSF calls Java Method
Java method is a native method Calls RPG
Sub-Procedure
15
Java Server Faces Navigation
faces-config.xml ltnavigation-rulegt
ltfrom-view-idgt/Login.jsplt/from-view-idgt
ltnavigation-casegt
ltfrom-outcomegt1lt/from-outcomegt
ltto-view-idgt/welcome.jsplt/to-view-idgt
lt/navigation-casegt ltnavigation-casegt
ltfrom-outcomegt0lt/from-outcomegt
ltto-view-idgt/Login.jsplt/to-view-idgt
lt/navigation-casegt lt/navigation-rulegt
16
Conclusion
The integration of JSP and RPG can provide AS/400
developers unaccustomed to java development an
inroad to more rapid web development.
RPG using JSP integration can get/set variables
normally only reserved for java objects from the
Apache HTTP/Tomcat JSP server.
17
Thank You and support your GCMUG
Write a Comment
User Comments (0)
About PowerShow.com