SlideShare a Scribd company logo
1 of 78
Download to read offline
JSPs, Resources &
Internationalization
Leland Bartlett & Lavanya Devarajan
 SAP AG 2002, Title of Presentation, Speaker Name 2
WelcomeWelcomeWelcomeWelcome
! Target audience:
" Anyone interested in understanding how to integrate Java Server Pages, other
resources (HTML, JavaScript and Applets), re-use classes and resources and the
basics of internationalization.
! Skills Needed
" Familiar with HTML, Java Server Pages
" Familiar with Java Programming Concepts
 SAP AG 2002, Title of Presentation, Speaker Name 3
Using Java Server Pages
Using Resources
Internationalization
AgendaAgendaAgendaAgenda
Re-Using Resources & Classes
 SAP AG 2002, Title of Presentation, Speaker Name 4
Using Java Server Pages
Using Resources
Internationalization
Unit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & Internationalization
Re-Using Resources & Classes
 SAP AG 2002, Title of Presentation, Speaker Name 5
Using Java Server PagesUsing Java Server PagesUsing Java Server PagesUsing Java Server Pages
! JSPs & Java iView runtime
! JSPs & HTMLB
! Methods for JSP integration
 SAP AG 2002, Title of Presentation, Speaker Name 6
JSPsJSPsJSPsJSPs & Java iView runtime& Java iView runtime& Java iView runtime& Java iView runtime
myjsp.jsp
public class _sapportalsjsp_myjsp extends AbstractPortalComponent implements
INonCachablePortalComponent
{
public void doContent(IPortalComponentRequest componentRequest,
IPortalComponentResponse aResponse)
{
HttpServletRequest request = componentRequest.getServletRequest();
JSPResponse response = new JSPResponse(aResponse);
JspFactoryImpl factory = new JspFactoryImpl();…
The Java iView Runtime(PRT) provides support for Java Server Pages by compiling
the JSPs to Portal Components (standard JSPs are compiled to HttpServlets).
Compiled JSPs can be found under:
%TOMCAT_HOME%webappsirjWEB-INFpluginsportalresources<component name>work
Note:
In order to compile the generated JSP pages at run-time the PRT needs the tools.jar file of the JDK. By default
tools.jar is retrieved with the system property java.home defined by the JDK. If tools.jar is not in the java.home folder
the property "jsp.addclasspath" in the file "workplace.properties" can be used to define the location of the tools.jar
file.
%TOMCAT_HOME%webappsirjWEB-INFpluginsportal systemproperties
Compiled to AbstractPortalComponent
 SAP AG 2002, Title of Presentation, Speaker Name 7
JSPs & Java iView runtimeJSPs & Java iView runtimeJSPs & Java iView runtimeJSPs & Java iView runtime ImpImpImpImplicit Objects
Original Request object.javax.servlet.http.HttpServletRequestrequestrequest
out
session
pageContext
response
componentRequest
JSP iView Object
javax.servlet.jsp.JspWriterout
Specific Portal
implementation.
javax.servlet.http.HttpSessionsession
Not fully supportedjavax.servlet.jsp.PageContextpageContext
The Portal Component
Response.
com.sapportals.portal.prt.IPortalCom
ponentResponse
response
The Portal Component
Request.
com.sapportals.portal.prt.IPortalCom
ponentRequest
---
CommentsClass
Similar
standard JSP
Object
Only available on Error
Page.
Java.lang.Throwableexceptionexception
javax.servlet.ServletConfigconfigconfig
Directives: page, include supported
http://localhost:8080/irj/resources/com.sapportals.pdk.documentation.HowToDevelopMyPortalComponent/docs/JSP_Support.html
 SAP AG 2002, Title of Presentation, Speaker Name 8
Using Java Server PagesUsing Java Server PagesUsing Java Server PagesUsing Java Server Pages
! JSPs & Java iView runtime
! JSPs & HTMLB
! Methods for JSP integration
 SAP AG 2002, Title of Presentation, Speaker Name 9
JSPs & HTMLBJSPs & HTMLBJSPs & HTMLBJSPs & HTMLB
.Java
TextView t = new TextView();
t.setText("Hello World!");
JSP:
<hbj:textView text="Hello World"/>
Wrap components with custom JSP tags !
 SAP AG 2002, Title of Presentation, Speaker Name 10
JSPs & HTMLBJSPs & HTMLBJSPs & HTMLBJSPs & HTMLB Important Stuff!!!!
The physical location of the HTMLB tag library:
" %TOMCAT_HOME% webappsirjserviceshtmlbtaglib
Using the Taglib Provided by Portal services
All JSP that are compiled into a Portal Component can use tag libraries provided
by the PRT services (e.g. HTML-Business for Java (HTMLB)).
" The tag library definition file must be referenced in the property file of the Portal
Component.
$ tagLib.value =/SERVICE/htmlb/taglib/htmlb.tld
" Within the JSP file itself the tab library needs to be referenced
$ At the beginning of the JSP file that is using the tag library the custom tag library
definition property has to be declared:
$ <%@ taglib uri="tagLib" prefix="hbj" %>
Examples
1. Entries in property file default.properties to use the HTMLB service and tag
library:
2. Beginning of JSP file that is using HTMLB tags
 SAP AG 2002, Title of Presentation, Speaker Name 11
JSPs & HTMLBJSPs & HTMLBJSPs & HTMLBJSPs & HTMLB
<%@taglib uri="tagLib" prefix="hbj" %>
<hbj:content id="myContext" >
<hbj:page title="Hello World">
<hbj:form>
<hbj:textView id="welcome">
<%
welcome.setText("Hello World");
%>
</hbj:textView>
</hbj:form>
</hbj:page>
</hbj:content>
Hello worldHello worldHello worldHello world …………Using JSPsUsing JSPsUsing JSPsUsing JSPs
 SAP AG 2002, Title of Presentation, Speaker Name 12
Using Java Server PagesUsing Java Server PagesUsing Java Server PagesUsing Java Server Pages
! JSPs & Java iView runtime
! JSPs & HTMLB
! Methods for JSP integration
 SAP AG 2002, Title of Presentation, Speaker Name 13
Methods for JSP integrationMethods for JSP integrationMethods for JSP integrationMethods for JSP integration
! JSPDynpage
! JSPNative
 SAP AG 2002, Title of Presentation, Speaker Name 14
JSPDynPageJSPDynPageJSPDynPageJSPDynPage
! JSPDynpage Model
! Usage of Beans
! Example
 SAP AG 2002, Title of Presentation, Speaker Name 15
DynPage
Extends PageProcessorComponent
JSPDynPage ModelJSPDynPage ModelJSPDynPage ModelJSPDynPage Model
AbstractPortalComponent implements
IPortalComponent Interface
public abstract class
PageProcessorComponent extends
AbstractPortalComponent
PageProcessorComponent is the base
class for Htmlb component that want to
use the DynPage programming model
within the Portal Runtime
JSPDynPage is a special implementation
to enable usage of a DynPage in
combination with JSPs in the Portal
environment.
First step is to define a class that works as
loader class - it inherits from the
PageProcessorComponent. The created
loader class executes the method
getPage() and returns a unique value of
the JSP DynPage
AbstractPortalComponent
Implements
IPortalComponent Interface
PageProcessorComponent
Extends AbstractPortalComponent
Introducing JSPDynPage Model
JSPDynPage
Extends DynPage
 SAP AG 2002, Title of Presentation, Speaker Name 16
JSPDynpageJSPDynpageJSPDynpageJSPDynpage ModelModelModelModel
Request
doProcessAfterInput
JSPDynPage
PageProcessorComponent
doInitialization
doProcessBeforeOutput
 SAP AG 2002, Title of Presentation, Speaker Name 17
JSPDynPageJSPDynPageJSPDynPageJSPDynPage
! JSPDynpage Model
! Usage of Beans
! Example
 SAP AG 2002, Title of Presentation, Speaker Name 18
Usage of BeanUsage of BeanUsage of BeanUsage of Bean
For complex applications, it is suitable to separate not only the logic from the view, but also the
data from the logic.
This leads to a Model-View-Controller architecture:
JspDynPage
(Controller)
Data Bean (Model) JSP (View)
Request
Response
 SAP AG 2002, Title of Presentation, Speaker Name 19
Usage of BeanUsage of BeanUsage of BeanUsage of Bean
Bean
The bean concept - reusable components that can be used in more than one software package - plays an important
role in the portal component development. Portal components can use the beans to store and retrieve data. The
JSP as well as the servlet (JSPDynPage, AbstractPortalComponent, DynPage, Native servlet) have read and write
access to the bean so the bean can be used to transfer data between the JSP and the servlet.
Bean
%JSPDynPage and JSP data exchange using a Bean
%A bean is used to get and set "dynamic" data. The JSPDynPage usually provides the bean with
data and the JSP reads the data. The functionality of the basic example is extended by an input
field that allows user input. The user input is stored in a bean and than displayed as text by a
JSP program.
Following steps are necessary
%create a bean
%initialize the bean
%Access the bean in the JSP program (where bean data is required)
 SAP AG 2002, Title of Presentation, Speaker Name 20
Usage of BeanUsage of BeanUsage of BeanUsage of Bean
In a JSP page, one can access Java Bean
objects using the tag
<jsp:useBean
id="object name"
scope="application|session|reque
st|page"
class="class name" />
where
" id is the name of the bean object in the compiled JSP
" scope can be
$ application -> the bean is stored in the associated component profile object
$ session -> the bean is stored in the associated HttpSession or
IPortalComponentSession object
$ request -> the bean is stored in the associated HttpServletRequest object
$ page -> the bean is stored in the associated javax.servlet.jsp.PageContext
object
" class is the fully qualified classname of the bean
 SAP AG 2002, Title of Presentation, Speaker Name 21
JSPDynPageJSPDynPageJSPDynPageJSPDynPage
! JSPDynpage Model
! Usage of Beans
! Example
 SAP AG 2002, Title of Presentation, Speaker Name 22
ExampleOneExampleOneExampleOneExampleOne
Bean
2) OnSubmit
1) Initial form is displayed
3) Sends info to bean
4) Receives info from bean
5) Renders results
 SAP AG 2002, Title of Presentation, Speaker Name 23
ExampleOneExampleOneExampleOneExampleOne Parts
processForm.java (extends the JSPDynPage)
" Supplies the logic and calls the required JSP file
" Handles the Event
" Populates the bean with user input
Form.jsp
" GUI Form for the end user to enter data
Result.jsp
" Retrieves the data from the bean
" Displays the data
DynPageNameBean.java
" Allows to “Set” and “Get data
 SAP AG 2002, Title of Presentation, Speaker Name 24
ExampleOneExampleOneExampleOneExampleOne
Form.jsp
Result.jsp
processForm
(Controller)
DynPageNameBean
 SAP AG 2002, Title of Presentation, Speaker Name 25
Writing the CodeWriting the CodeWriting the CodeWriting the Code
Note the location of
the JSPs
 SAP AG 2002, Title of Presentation, Speaker Name 26
Writing the CodeWriting the CodeWriting the CodeWriting the Code Setting VariablesSetting VariablesSetting VariablesSetting Variables
;
Variables defined to
evaluate which JSP
file to process
Variables to store
data
 SAP AG 2002, Title of Presentation, Speaker Name 27
Writing the CodeWriting the CodeWriting the CodeWriting the Code doInitialization
Sets the variable state to the value of
INITITAL_STATE: Which had a static value of 0.
 SAP AG 2002, Title of Presentation, Speaker Name 28
Writing the CodeWriting the CodeWriting the CodeWriting the Code doProcessBeforeOutput
=INITIAL_STATE
Default location:
privatepagelet
 SAP AG 2002, Title of Presentation, Speaker Name 29
Writing the CodeWriting the CodeWriting the CodeWriting the Code Form.JSP
FirstName
LastName
Email
 SAP AG 2002, Title of Presentation, Speaker Name 30
Writing the CodeWriting the CodeWriting the CodeWriting the Code HTMLB
 SAP AG 2002, Title of Presentation, Speaker Name 31
Writing the CodeWriting the CodeWriting the CodeWriting the Code Button
 SAP AG 2002, Title of Presentation, Speaker Name 32
Writing the CodeWriting the CodeWriting the CodeWriting the Code doProcessAfterInput
1
2
3
4
 SAP AG 2002, Title of Presentation, Speaker Name 33
Writing the CodeWriting the CodeWriting the CodeWriting the Code doProcessBeforeOutput
State=WELCOME_STATE
 SAP AG 2002, Title of Presentation, Speaker Name 34
Writing the CodeWriting the CodeWriting the CodeWriting the Code Result.JSP
 SAP AG 2002, Title of Presentation, Speaker Name 35
Writing the CodeWriting the CodeWriting the CodeWriting the Code The Bean
Sent here after the processForm reads
the data inputed by the use and
extracted from the input fields. This
stores the data until it is requested for
either examination or output.
 SAP AG 2002, Title of Presentation, Speaker Name 36
Writing the CodeWriting the CodeWriting the CodeWriting the Code Profile
 SAP AG 2002, Title of Presentation, Speaker Name 37
ExampleOne Recap
 SAP AG 2002, Title of Presentation, Speaker Name 38
Methods for JSP integrationMethods for JSP integrationMethods for JSP integrationMethods for JSP integration
! JSPDynpage
! JSPNative
 SAP AG 2002, Title of Presentation, Speaker Name 39
JSPNativeJSPNativeJSPNativeJSPNative
Profile
ComponentType=jspnative
JSP=Name of the JSP File
tagLib=/SERVICE/htmlb/taglib/htmlb.tld
ServicesReference=htmlb
&JSPNative:
A Portal Component is simply written as one JSP which is compiled to a Portal
Component at runtime. Set the profile property ComponentType to jspnative
In the .par file, the JSP should be located under privatejsp
(If folder JSP does not exist previously, it needs to be created)
 SAP AG 2002, Title of Presentation, Speaker Name 40
Using Java Server Pages
Using Resources
Unit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & Internationalization
Internationalization
Re-Using Resources & Classes
 SAP AG 2002, Title of Presentation, Speaker Name 41
Using ResourcesUsing ResourcesUsing ResourcesUsing Resources
Resources can either be basic resources like applets, scripts, images, static pages or more complex
resources like xml files or even java properties files. If you want to use resources in your Portal component,
you have to declare in your component where to find the resources with the help of methods from the
IResource interface (Portal Runtime API)
Here are some supported resource types and their default scopes & extensions :
SCRIPT (Public) (.js)
STATIC_PAGE (Public) (.html)
APPLET (Public)
IMAGE (Public) (.gif)
JSP (Private) (.jsp)
XML (Private) (.xml)
PROFILE (Private) (.properties)
How to use resources:
Fetch the resource from the IPortalComponentRequest interface. This returns an Iresource object. Now you
can add it to the response by calling the IPortalComponentResponse.addResource(IResource) method.
 SAP AG 2002, Title of Presentation, Speaker Name 42
Using ResourcesUsing ResourcesUsing ResourcesUsing Resources
Recommended file structure for Resources:
applet*
* Indicates that folder names can be custom names
Where are they stored when .par file is deployed?
Private: %TOMCAT_HOME%webappsirjWEB-INFpluginsportalresources<.par name>
Public: %TOMCAT_HOME%webappsirjresources<.par name>
…
Private
Public
images*
html*
scripts*
profiles
jsp (jspnative approach)
pagelet (JspDynpage approach)
xml*
…
Generated Web URL for Public Resources:
http://localhost:8080/irj/resources/<par file name> /<Folder Name>/<File name>
You can use any folder names for those
under the public folder.
The Generated web url is purely for your
information, you don’t need to know this
as you will be using the iresource
methods as you will see in the following
slides.
 SAP AG 2002, Title of Presentation, Speaker Name 43
Using ResourcesUsing ResourcesUsing ResourcesUsing Resources
! Using Images & HTML Pages
! Using JavaScript
! Using Applets
! JSP again!
 SAP AG 2002, Title of Presentation, Speaker Name 44
Images: Under the Public folder, place your images (.gif) in any folder. Let us say we have an image
under the following location:
public
images
garfield.gif
How to access it?
IResource garfield = componentrequest.getResource(IResource.IMAGE,"images/garfield.gif"); or
IResource garfield = componentrequest.getResource(IResource.IMAGE,"images/garfield"); //since default extension is .gif
componentresponse.addResource(garfield);
or
Image logo;
logo=new Image(garfield.getResourceInformation().getURL(req),"Logo");
myForm.addComponent(logo);
HTML: Under the Public folder, place your HTML (.html) in any folder. Let us say we have an HTML
Page under the following location:
public
html
simple.html
Similarly, IResource myhtml= componentrequest.getResource(IResource.STATIC_PAGE,"html/simple.html");
componentresponse.addResource(myhtml);
Using Images & HTML PagesUsing Images & HTML PagesUsing Images & HTML PagesUsing Images & HTML Pages
 SAP AG 2002, Title of Presentation, Speaker Name 45
Using ResourcesUsing ResourcesUsing ResourcesUsing Resources
! Using Images & HTML Pages
! Using JavaScript
! Using Applets
! JSP again!
 SAP AG 2002, Title of Presentation, Speaker Name 46
Using JavaScriptUsing JavaScriptUsing JavaScriptUsing JavaScript
Some Methods:
1. Under the Public folder, create a folder say, scripts and place your .js file.
2. Create an HTMLB fragment and add to the class
3. Use <script></script> tags in JSP
Let us say we have a .js file named myscript.js containing a function runme()
IResource jsResource = componentRequest.getResource(IResource.SCRIPT, "script/myscript.js");
componentresponse.addResource(jsResource);
1. .js file in scripts folder
 SAP AG 2002, Title of Presentation, Speaker Name 47
Using JavaScriptUsing JavaScriptUsing JavaScriptUsing JavaScript
2. Create an HTMLFragment element (HTMLB element)
String frag= new String(" <SCRIPT language=JavaScript>");
frag = frag + " function runme(siteName,userName,pwd){";
frag = frag+…
frag = frag + "}";
frag = frag + "</SCRIPT>";
HTMLFragment hf=new HTMLFragment(frag);//Special container for raw HTML. Note that using this class
//might cause Browser dependencies
myForm.addComponent(hf);
3. Use <script> tags in JSP
<script>
function runme(){
…
}
</script>
 SAP AG 2002, Title of Presentation, Speaker Name 48
Using JavaScriptUsing JavaScriptUsing JavaScriptUsing JavaScript
If you want to access HTMLB elements via JavaScript, we recommend that you create you HTMLB
elements in JSP and use Method 3
How to invoke the JavaScript function?
Use htmlb elements that have onclient… methods- Button, Link, Drop Down List box
Mybutton.setOnClientClick(“runme()“)
or
via jsp
<hbj:button id=“Mybutton" text="Click!" onClientClick=“runme()"/>
Or
<script>runme();</script>
 SAP AG 2002, Title of Presentation, Speaker Name 49
Using JavaScriptUsing JavaScriptUsing JavaScriptUsing JavaScript
How to access HTMLB elements?
HTMLB provides access to the HTML IDs that are generated during runtime. After
retrieving the IDs, you can generate your JavaScript by setting the correct IDs at runtime.
% Declare String variables at the start of the JSP that will hold the HTML IDs of the
components you wish to access from JavaScript
% Use a method of the HTMLB com.sapportals.htmlb.rendering.PageContext class:
pageContext.getParamIdForComponent(com.sapportals.htmlb.Component
component). This method returns a String, and this String is the generated ID value
for the given component.
% Write the script and use this generated ID to identify you HTMLB element
% Invoke the script
Example:
<%String compid="";%>
<hbj:inputField id="InputName" type="string" maxlength="100">
<% compid=myContext.getParamIdForComponent(InputName);%>
</hbj:inputField>
<hbj:button id="button1" text="Type&Click!" onClientClick="runme()"/>
Needs to be placed before
</hbj:unputField>, to access
this inputField component
<script>
function runme() {
var myval=document.getElementById('<%=compid%>').value;
alert("You typed: "+myval); }
</script>
 SAP AG 2002, Title of Presentation, Speaker Name 50
Using ResourcesUsing ResourcesUsing ResourcesUsing Resources
! Using Images & HTML Pages
! Using JavaScript
! Using Applets
! JSP again!
 SAP AG 2002, Title of Presentation, Speaker Name 51
Using AppletsUsing AppletsUsing AppletsUsing Applets
How to access it?
IResource myapplet= req.getResource(IResource.APPLET,"applet/");
String myurl=myapplet.getResourceInformation().getURL(req);
componentresponse.write("<applet name="ChompText" archive="ChompText.zip" codebase=""+myurl+""
code="ChompText.class" width=250 height=55>");
componentresponse.write("<param name="text" value="Java Boutique">");
componentresponse.write("<param name="textcolor" value="0000FF">");
componentresponse.write("<param name="bgcolor" value="FFFFFF">");
componentresponse.write("</Applet>");
Under the Public folder, place your applet classes (..jar, .zip) in any folder. Let us say we have an applet
ChompText.zip under the following location:
public
applet
ChompText.zip
zz
 SAP AG 2002, Title of Presentation, Speaker Name 52
Using ResourcesUsing ResourcesUsing ResourcesUsing Resources
! Using Images & HTML Pages
! Using JavaScript
! Using Applets
! JSP again!
 SAP AG 2002, Title of Presentation, Speaker Name 53
Under the Private folder, place your JSPs (.jsp) in any folder. Let us say we have a jsp under the following
location:
private
jsp
private.jsp
How to access it?
IResource myjsp= componentrequest.getResource(IResource.JSP,"jsp/private.jsp");
componentrequest.dispatchRequest(myjsp,componentresponse);
or
componentresponse.addResource(myjsp);
Using JSPsUsing JSPsUsing JSPsUsing JSPs
Note: JSPs as Web URLS is Not reccommended
 SAP AG 2002, Title of Presentation, Speaker Name 54
Using Java Server Pages
Using Resources
Unit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & Internationalization
Internationalization
Re-Using Resources & Classes
 SAP AG 2002, Title of Presentation, Speaker Name 55
ReReReRe----Using Resources & ClassesUsing Resources & ClassesUsing Resources & ClassesUsing Resources & Classes
! Re-Using Resources
! Re-Using Classes
 SAP AG 2002, Title of Presentation, Speaker Name 56
ReReReRe----Using ResourcesUsing ResourcesUsing ResourcesUsing Resources
You can reuse the resources from an existing .par file. You need to know the
name of the .par file that contains the resources.
You can then get the resource from the componentrequest
Example:
IResource myimage=
componentrequest.getResource(“SimpleExample.default",IResource.IMAGE,"images/SAPPortals_opt2.gif");
componentresponse.addResource(myimage);
 SAP AG 2002, Title of Presentation, Speaker Name 57
ReReReRe----Using Resources & ClassesUsing Resources & ClassesUsing Resources & ClassesUsing Resources & Classes
! Re-Using Resources
! Re-Using Classes
 SAP AG 2002, Title of Presentation, Speaker Name 58
ReReReRe----Using ClassesUsing ClassesUsing ClassesUsing Classes
How to re-use existing classes / External Libraries?
Method One
You have some classes (.jar file) in the lib folder of a .par file (A) that you want to use in another .par file (B)
You don't have to package the .jars again in the lib folder.
In the default.properties of the .par file (A) containing the .jar files, make the following entry:
SharingAccess=shared
This determines access to the package using the SharingReference property.
In the default.properties of the .par file (B), make the following entry:
SharingReference= .par file (A) name
This declares references to par file (A). This creates a sharing dependency, which requires that the .par file
(A) be uploaded beforehand in the PDK/Portal. For more than one reference, the list of package names must
be separated by a comma.
 SAP AG 2002, Title of Presentation, Speaker Name 59
ReReReRe----Using ClassesUsing ClassesUsing ClassesUsing Classes Some More Alternatives
How to re-use existing classes?
Method Two
'Package as a Portal Service (Not in the scope of this class)
Method Three
'Include in class-path (Not Reccomended)
In the PDK, you can copy the .jar files to <Tomcat_home>libapps. This will be loaded by the
Portal runtime.
Migration to Enterprise Portal:
Upload the .par file and create Java iView based on Master. Make sure you add the External
libraries to the Servlet Engine's class-path
Tip for SAPJ2EE Engine
Copy the .jar files to <SAPJ2EE_Home>aloneadditional-lib. Use the Config tool, Click on
"alone" and edit the Java parameters.
Example:
-classpath".;.system-libboot.jar;.system-libjaas.jar;.additional-libyourexternallib.jar;"
This is a good step to follow if you are using any of the libraries in
<SAPJ2EE_Home>aloneadditional-lib.
Disadvantages:
&Extra steps to be performed while migrating to other Enterprise Portals
&Classes are visible for all iViews
&Version conflicts can occur
 SAP AG 2002, Title of Presentation, Speaker Name 60
Using Java Server Pages
Using Resources
Unit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & Internationalization
Internationalization
Re-Using Resources & Classes
 SAP AG 2002, Title of Presentation, Speaker Name 61
InternationalizationInternationalizationInternationalizationInternationalization
! Methodology
! Example
 SAP AG 2002, Title of Presentation, Speaker Name 62
MethodologyMethodologyMethodologyMethodology
Language support for Java iViews is by use of Java resource bundles. The Java iView runtime
provides API that allow an iView to communicate with the resource bundle containing the text to
display in the iView.
Know the ISO88559-1 Country Codes for language wanted to translate
" Know the languages Enterprise Portal supported
Localization files need to exist under the folder private/classes
For each language wanted to translate a localization_xx.properties file needs to be created
" German: localization_de.properties
" Spanish: localization_es.properties
" Default Language: localization.properties
If you want to name your translation files something else other than localization_xx.properties, there
must be a reference to it in the default.properties file.
Example: ExampleOne_de.properties, ExampleOne_es.properties
Specify localization file name in default.properties
ResourceBundleName=ExampleOne
 SAP AG 2002, Title of Presentation, Speaker Name 63
MethodologyMethodologyMethodologyMethodology
For Translating Strings
Access the language resource in your code
<% Import java.util.ResourceBundle; %>
<% ResourceBundle res = componentRequest.getResourceBundle();%>
<%Send_Button.setText(res.getString(“button.send"));%>
Sample Entry in localization_de.properties
button.send=Senden
For translating Personalization Parameter Names use the Description attribute
Any String
 SAP AG 2002, Title of Presentation, Speaker Name 64
Language SettingsLanguage SettingsLanguage SettingsLanguage Settings
To run the iView in a different language in the PDK, the following needs to be done
Locate the file workplace.properties
<Tomcat_Home>webappsirjWEB-INFpluginsportalsystemproperties
Look for
request.mandatorylanguage=en
Remove it this entry (or comment #)
Now restart tomcat.
Change the Language for Internet Explorer (or)
" The language has to be one that is supported by the portal
Change the user locale in Kmusers.properties
Precedence
1. Locale of the PDK (if specified in workplace.properties)
2. Locale of the user (if specified in kMusers.properties)
3. Locale of the client ( [i.e. if set up in (e.g.) IE under Tools/Internet Options/Languages...])
 SAP AG 2002, Title of Presentation, Speaker Name 65
Language SettingsLanguage SettingsLanguage SettingsLanguage Settings
Forcing a language in PDK
• If the desired effect is for the PDK to be displayed in a particular language regardless of browser settings or user
setting then the
• Workplace.properties
• request.mandatorylanguage=ISO Language requirement
If the entry in workplace.properties is removed:
• Language of Browser
• PDK is displayed initially with this language
• If language not supported, PDK defaults to English
• User Locale
• Language changes based on logged on user’s locale in KMusers.properties
• If no user locale is specified, then browser language is displayed
Example
Browser Setting = Spanish (es)
User Locale= German (de)
Results:
" PDK HomePage= Spanish
User logs on
" PDK = German
" IView = German (If no specific localization file exists for german, the iView runs in the default
localization)
 SAP AG 2002, Title of Presentation, Speaker Name 66
Forcing PDK Mandatory LanguageForcing PDK Mandatory LanguageForcing PDK Mandatory LanguageForcing PDK Mandatory Language
To change the mandatory language for the PDK,
this needs to be set. Note! It takes precedence
If you want the PDK to render content in the language of the
browser or the language of the user, the variable described here
needs to be commented out
Locate the file workplace.properties
<Tomcat_Home>webappsirjWEB-INFpluginsportalsystemproperties
 SAP AG 2002, Title of Presentation, Speaker Name 67
User LocaleUser LocaleUser LocaleUser Locale
<Tomcat_Home>webappsirjWEB-INFpluginsportalservicesusermanagementdata
In the kmusers.properties file there is a list of the PDK users
 SAP AG 2002, Title of Presentation, Speaker Name 68
Language Setting in IELanguage Setting in IELanguage Setting in IELanguage Setting in IE
 SAP AG 2002, Title of Presentation, Speaker Name 69
InternationalizationInternationalizationInternationalizationInternationalization
! Methodology
! Example
 SAP AG 2002, Title of Presentation, Speaker Name 70
ExampleExampleExampleExample
Internationalize ExampleOne
" The languages we will use are Spanish, German, English (default)
" We will “Internationalize” the initial form Form.jsp.
$ Labels
$ Text for the button
 SAP AG 2002, Title of Presentation, Speaker Name 71
ExampleOneExampleOneExampleOneExampleOne Form.jsp
 SAP AG 2002, Title of Presentation, Speaker Name 72
“Internationalize” Form.jsp:“Internationalize” Form.jsp:“Internationalize” Form.jsp:“Internationalize” Form.jsp: Labels
Use
label_FirstName.setText(res.getString(“label.firstName”))
But you need to place it before the closing tag of <hbj:
label…>
This will be the string we will use in the
localization file
 SAP AG 2002, Title of Presentation, Speaker Name 73
“Internationalize” Form.jsp:“Internationalize” Form.jsp:“Internationalize” Form.jsp:“Internationalize” Form.jsp: Button
 SAP AG 2002, Title of Presentation, Speaker Name 74
Localization FilesLocalization FilesLocalization FilesLocalization Files
" First we need to create a localization file (for a default language, say English) named
localization.properties
" Create the localization.properties, localization_xx.properties, under the src folder of
project. When you compile/create .par, the localization file will move to the right location
under private/classes.
 SAP AG 2002, Title of Presentation, Speaker Name 75
Localization FilesLocalization FilesLocalization FilesLocalization Files
localization.properties
 SAP AG 2002, Title of Presentation, Speaker Name 76
Localization FilesLocalization FilesLocalization FilesLocalization Files
In order to access a String in German, Spanish and a default representation (say English),
you would have the following structure:
label.firstName=Given Name
label.lastName=Family Name
label.email= Rapid Mail
button.send=Fire it off!
label.firstName=Vorname
label.lastName=Nachname
label.email= e-mail Adresse
button.send=Senden
label.firstName=il primo nome
label.lastName=l'ultimo nome
label.email= correo electrónico
button.send=mande
 SAP AG 2002, Title of Presentation, Speaker Name 77
SummarySummarySummarySummary
You now know:
! Different methods to Integrate JSPs
! How to use resources such as JavaScripts, HTML & Applets
! How to re-use resources and classes
! How to use Language resource bundles to perform Internationalization
 SAP AG 2002, Title of Presentation, Speaker Name 78
" No part of this publication may be reproduced or transmitted in any form or for any purpose without the express
permission of SAP AG. The information contained herein may be changed without prior notice.
" Some software products marketed by SAP AG and its distributors contain proprietary software components of other
software vendors.
" Microsoft®, WINDOWS®, NT®, EXCEL®, Word®, PowerPoint® and SQL Server® are registered trademarks of
Microsoft Corporation.
" IBM®, DB2®, DB2 Universal Database, OS/2®, Parallel Sysplex®, MVS/ESA, AIX®, S/390®, AS/400®, OS/390®,
OS/400®, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere®, Netfinity®, Tivoli®,
Informix and Informix® Dynamic ServerTM are trademarks of IBM Corporation in USA and/or other countries.
" ORACLE® is a registered trademark of ORACLE Corporation.
" UNIX®, X/Open®, OSF/1®, and Motif® are registered trademarks of the Open Group.
" Citrix®, the Citrix logo, ICA®, Program Neighborhood®, MetaFrame®, WinFrame®, VideoFrame®, MultiWin® and
other Citrix product names referenced herein are trademarks of Citrix Systems, Inc.
" HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C®, World Wide Web Consortium,
Massachusetts Institute of Technology.
" JAVA® is a registered trademark of Sun Microsystems, Inc.
" JAVASCRIPT® is a registered trademark of Sun Microsystems, Inc., used under license for technology invented
and implemented by Netscape.
" MarketSet and Enterprise Buyer are jointly owned trademarks of SAP AG and Commerce One.
" SAP, SAP Logo, R/2, R/3, mySAP, mySAP.com and other SAP products and services mentioned herein as well as
their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other
countries all over the world. All other product and service names mentioned are trademarks of their respective
companies.
Copyright 2002 SAP AG. All Rights Reserved

More Related Content

What's hot

JSP - Part 2 (Final)
JSP - Part 2 (Final) JSP - Part 2 (Final)
JSP - Part 2 (Final) Hitesh-Java
 
Introduction to JSP
Introduction to JSPIntroduction to JSP
Introduction to JSPFulvio Corno
 
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on RailsContent-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Railsbkraft
 
Java Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXJava Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXIMC Institute
 
Servlet and jsp interview questions
Servlet and jsp interview questionsServlet and jsp interview questions
Servlet and jsp interview questionsSujata Regoti
 
Java Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVCJava Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVCIMC Institute
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server PageVipin Yadav
 
JAVA SERVER PAGES
JAVA SERVER PAGESJAVA SERVER PAGES
JAVA SERVER PAGESKalpana T
 
ADP- Chapter 3 Implementing Inter-Servlet Communication
ADP- Chapter 3 Implementing Inter-Servlet CommunicationADP- Chapter 3 Implementing Inter-Servlet Communication
ADP- Chapter 3 Implementing Inter-Servlet CommunicationRiza Nurman
 
Java Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicJava Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicIMC Institute
 
ADP - Chapter 5 Exploring JavaServer Pages Technology
ADP - Chapter 5 Exploring JavaServer Pages TechnologyADP - Chapter 5 Exploring JavaServer Pages Technology
ADP - Chapter 5 Exploring JavaServer Pages TechnologyRiza Nurman
 
Session 37 - JSP - Part 2 (final)
Session 37 - JSP - Part 2 (final)Session 37 - JSP - Part 2 (final)
Session 37 - JSP - Part 2 (final)PawanMM
 

What's hot (20)

JSP - Part 2 (Final)
JSP - Part 2 (Final) JSP - Part 2 (Final)
JSP - Part 2 (Final)
 
Introduction to JSP
Introduction to JSPIntroduction to JSP
Introduction to JSP
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
 
JSP Directives
JSP DirectivesJSP Directives
JSP Directives
 
Jsp Slides
Jsp SlidesJsp Slides
Jsp Slides
 
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on RailsContent-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
 
Java Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXJava Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAX
 
Servlet and jsp interview questions
Servlet and jsp interview questionsServlet and jsp interview questions
Servlet and jsp interview questions
 
J2EE jsp_01
J2EE jsp_01J2EE jsp_01
J2EE jsp_01
 
Java Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVCJava Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVC
 
Jsp presentation
Jsp presentationJsp presentation
Jsp presentation
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server Page
 
JAVA SERVER PAGES
JAVA SERVER PAGESJAVA SERVER PAGES
JAVA SERVER PAGES
 
Jsp slides
Jsp slidesJsp slides
Jsp slides
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
ADP- Chapter 3 Implementing Inter-Servlet Communication
ADP- Chapter 3 Implementing Inter-Servlet CommunicationADP- Chapter 3 Implementing Inter-Servlet Communication
ADP- Chapter 3 Implementing Inter-Servlet Communication
 
Java Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicJava Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet Basic
 
ADP - Chapter 5 Exploring JavaServer Pages Technology
ADP - Chapter 5 Exploring JavaServer Pages TechnologyADP - Chapter 5 Exploring JavaServer Pages Technology
ADP - Chapter 5 Exploring JavaServer Pages Technology
 
Struts N E W
Struts N E WStruts N E W
Struts N E W
 
Session 37 - JSP - Part 2 (final)
Session 37 - JSP - Part 2 (final)Session 37 - JSP - Part 2 (final)
Session 37 - JSP - Part 2 (final)
 

Viewers also liked

Memcache - Lightning fast object retrieval
Memcache - Lightning fast object retrievalMemcache - Lightning fast object retrieval
Memcache - Lightning fast object retrievalelliando dias
 
Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...ColdFusionConference
 
Predicting Defects in SAP Java Code: An Experience Report
Predicting Defects in SAP Java Code: An Experience ReportPredicting Defects in SAP Java Code: An Experience Report
Predicting Defects in SAP Java Code: An Experience Reporttilman.holschuh
 
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...elliando dias
 
SAP Integration with Red Hat JBoss Technologies
SAP Integration with Red Hat JBoss TechnologiesSAP Integration with Red Hat JBoss Technologies
SAP Integration with Red Hat JBoss Technologieshwilming
 
Memcached: What is it and what does it do? (PHP Version)
Memcached: What is it and what does it do? (PHP Version)Memcached: What is it and what does it do? (PHP Version)
Memcached: What is it and what does it do? (PHP Version)Brian Moon
 
The new ehcache 2.0 and hibernate spi
The new ehcache 2.0 and hibernate spiThe new ehcache 2.0 and hibernate spi
The new ehcache 2.0 and hibernate spiCyril Lakech
 
Why Memcached?
Why Memcached?Why Memcached?
Why Memcached?Gear6
 
Memcached and the Rise of the Dynamic Web
Memcached and the Rise of the Dynamic WebMemcached and the Rise of the Dynamic Web
Memcached and the Rise of the Dynamic WebGear6
 
Practical SAP pentesting workshop (NullCon Goa)
Practical SAP pentesting workshop (NullCon Goa)Practical SAP pentesting workshop (NullCon Goa)
Practical SAP pentesting workshop (NullCon Goa)ERPScan
 
Integrating SAP the Java EE Way - JBoss One Day talk 2012
Integrating SAP the Java EE Way - JBoss One Day talk 2012Integrating SAP the Java EE Way - JBoss One Day talk 2012
Integrating SAP the Java EE Way - JBoss One Day talk 2012hwilming
 
Low latency Java apps
Low latency Java appsLow latency Java apps
Low latency Java appsSimon Ritter
 
Sap java connector / Hybris RFC
Sap java connector / Hybris RFCSap java connector / Hybris RFC
Sap java connector / Hybris RFCMonsif Elaissoussi
 
Scaling and securing node.js apps
Scaling and securing node.js appsScaling and securing node.js apps
Scaling and securing node.js appsMaciej Lasyk
 
Overview of the ehcache
Overview of the ehcacheOverview of the ehcache
Overview of the ehcacheHyeonSeok Choi
 
Implementing High Availability Caching with Memcached
Implementing High Availability Caching with MemcachedImplementing High Availability Caching with Memcached
Implementing High Availability Caching with MemcachedGear6
 
Integrating Node.js with PHP
Integrating Node.js with PHPIntegrating Node.js with PHP
Integrating Node.js with PHPLee Boynton
 

Viewers also liked (20)

Sap java
Sap javaSap java
Sap java
 
Memcache - Lightning fast object retrieval
Memcache - Lightning fast object retrievalMemcache - Lightning fast object retrieval
Memcache - Lightning fast object retrieval
 
Memcache
MemcacheMemcache
Memcache
 
Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...
 
SAP and Red Hat JBoss Partner Webinar
SAP and Red Hat JBoss Partner WebinarSAP and Red Hat JBoss Partner Webinar
SAP and Red Hat JBoss Partner Webinar
 
Predicting Defects in SAP Java Code: An Experience Report
Predicting Defects in SAP Java Code: An Experience ReportPredicting Defects in SAP Java Code: An Experience Report
Predicting Defects in SAP Java Code: An Experience Report
 
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
 
SAP Integration with Red Hat JBoss Technologies
SAP Integration with Red Hat JBoss TechnologiesSAP Integration with Red Hat JBoss Technologies
SAP Integration with Red Hat JBoss Technologies
 
Memcached: What is it and what does it do? (PHP Version)
Memcached: What is it and what does it do? (PHP Version)Memcached: What is it and what does it do? (PHP Version)
Memcached: What is it and what does it do? (PHP Version)
 
The new ehcache 2.0 and hibernate spi
The new ehcache 2.0 and hibernate spiThe new ehcache 2.0 and hibernate spi
The new ehcache 2.0 and hibernate spi
 
Why Memcached?
Why Memcached?Why Memcached?
Why Memcached?
 
Memcached and the Rise of the Dynamic Web
Memcached and the Rise of the Dynamic WebMemcached and the Rise of the Dynamic Web
Memcached and the Rise of the Dynamic Web
 
Practical SAP pentesting workshop (NullCon Goa)
Practical SAP pentesting workshop (NullCon Goa)Practical SAP pentesting workshop (NullCon Goa)
Practical SAP pentesting workshop (NullCon Goa)
 
Integrating SAP the Java EE Way - JBoss One Day talk 2012
Integrating SAP the Java EE Way - JBoss One Day talk 2012Integrating SAP the Java EE Way - JBoss One Day talk 2012
Integrating SAP the Java EE Way - JBoss One Day talk 2012
 
Low latency Java apps
Low latency Java appsLow latency Java apps
Low latency Java apps
 
Sap java connector / Hybris RFC
Sap java connector / Hybris RFCSap java connector / Hybris RFC
Sap java connector / Hybris RFC
 
Scaling and securing node.js apps
Scaling and securing node.js appsScaling and securing node.js apps
Scaling and securing node.js apps
 
Overview of the ehcache
Overview of the ehcacheOverview of the ehcache
Overview of the ehcache
 
Implementing High Availability Caching with Memcached
Implementing High Availability Caching with MemcachedImplementing High Availability Caching with Memcached
Implementing High Availability Caching with Memcached
 
Integrating Node.js with PHP
Integrating Node.js with PHPIntegrating Node.js with PHP
Integrating Node.js with PHP
 

Similar to Intro To Sap Netweaver Java

Lap trinh web [Slide jsp]
Lap trinh web [Slide jsp]Lap trinh web [Slide jsp]
Lap trinh web [Slide jsp]Tri Nguyen
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...WebStackAcademy
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Ayes Chinmay
 
KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7phuphax
 
KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7phuphax
 
Ajax Tags Advanced
Ajax Tags AdvancedAjax Tags Advanced
Ajax Tags AdvancedAkramWaseem
 
Session 36 - JSP - Part 1
Session 36 - JSP - Part 1Session 36 - JSP - Part 1
Session 36 - JSP - Part 1PawanMM
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESYoga Raja
 

Similar to Intro To Sap Netweaver Java (20)

Lap trinh web [Slide jsp]
Lap trinh web [Slide jsp]Lap trinh web [Slide jsp]
Lap trinh web [Slide jsp]
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
 
Learning jsp
Learning jspLearning jsp
Learning jsp
 
JSP Part 2
JSP Part 2JSP Part 2
JSP Part 2
 
Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp in Servlet by Rj
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
 
Introduction to JSP.pptx
Introduction to JSP.pptxIntroduction to JSP.pptx
Introduction to JSP.pptx
 
4. jsp
4. jsp4. jsp
4. jsp
 
KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7
 
KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7
 
Ajax Tags Advanced
Ajax Tags AdvancedAjax Tags Advanced
Ajax Tags Advanced
 
Session 36 - JSP - Part 1
Session 36 - JSP - Part 1Session 36 - JSP - Part 1
Session 36 - JSP - Part 1
 
Java server pages
Java server pagesJava server pages
Java server pages
 
JSP - Part 1
JSP - Part 1JSP - Part 1
JSP - Part 1
 
10 jsp-scripting-elements
10 jsp-scripting-elements10 jsp-scripting-elements
10 jsp-scripting-elements
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
 
Web&java. jsp
Web&java. jspWeb&java. jsp
Web&java. jsp
 
Web&java. jsp
Web&java. jspWeb&java. jsp
Web&java. jsp
 
Jsp Presentation +Mufix "3"
Jsp Presentation +Mufix "3"Jsp Presentation +Mufix "3"
Jsp Presentation +Mufix "3"
 
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component DevelopmentEVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
 

Recently uploaded

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Intro To Sap Netweaver Java

  • 1. JSPs, Resources & Internationalization Leland Bartlett & Lavanya Devarajan
  • 2.  SAP AG 2002, Title of Presentation, Speaker Name 2 WelcomeWelcomeWelcomeWelcome ! Target audience: " Anyone interested in understanding how to integrate Java Server Pages, other resources (HTML, JavaScript and Applets), re-use classes and resources and the basics of internationalization. ! Skills Needed " Familiar with HTML, Java Server Pages " Familiar with Java Programming Concepts
  • 3.  SAP AG 2002, Title of Presentation, Speaker Name 3 Using Java Server Pages Using Resources Internationalization AgendaAgendaAgendaAgenda Re-Using Resources & Classes
  • 4.  SAP AG 2002, Title of Presentation, Speaker Name 4 Using Java Server Pages Using Resources Internationalization Unit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & Internationalization Re-Using Resources & Classes
  • 5.  SAP AG 2002, Title of Presentation, Speaker Name 5 Using Java Server PagesUsing Java Server PagesUsing Java Server PagesUsing Java Server Pages ! JSPs & Java iView runtime ! JSPs & HTMLB ! Methods for JSP integration
  • 6.  SAP AG 2002, Title of Presentation, Speaker Name 6 JSPsJSPsJSPsJSPs & Java iView runtime& Java iView runtime& Java iView runtime& Java iView runtime myjsp.jsp public class _sapportalsjsp_myjsp extends AbstractPortalComponent implements INonCachablePortalComponent { public void doContent(IPortalComponentRequest componentRequest, IPortalComponentResponse aResponse) { HttpServletRequest request = componentRequest.getServletRequest(); JSPResponse response = new JSPResponse(aResponse); JspFactoryImpl factory = new JspFactoryImpl();… The Java iView Runtime(PRT) provides support for Java Server Pages by compiling the JSPs to Portal Components (standard JSPs are compiled to HttpServlets). Compiled JSPs can be found under: %TOMCAT_HOME%webappsirjWEB-INFpluginsportalresources<component name>work Note: In order to compile the generated JSP pages at run-time the PRT needs the tools.jar file of the JDK. By default tools.jar is retrieved with the system property java.home defined by the JDK. If tools.jar is not in the java.home folder the property "jsp.addclasspath" in the file "workplace.properties" can be used to define the location of the tools.jar file. %TOMCAT_HOME%webappsirjWEB-INFpluginsportal systemproperties Compiled to AbstractPortalComponent
  • 7.  SAP AG 2002, Title of Presentation, Speaker Name 7 JSPs & Java iView runtimeJSPs & Java iView runtimeJSPs & Java iView runtimeJSPs & Java iView runtime ImpImpImpImplicit Objects Original Request object.javax.servlet.http.HttpServletRequestrequestrequest out session pageContext response componentRequest JSP iView Object javax.servlet.jsp.JspWriterout Specific Portal implementation. javax.servlet.http.HttpSessionsession Not fully supportedjavax.servlet.jsp.PageContextpageContext The Portal Component Response. com.sapportals.portal.prt.IPortalCom ponentResponse response The Portal Component Request. com.sapportals.portal.prt.IPortalCom ponentRequest --- CommentsClass Similar standard JSP Object Only available on Error Page. Java.lang.Throwableexceptionexception javax.servlet.ServletConfigconfigconfig Directives: page, include supported http://localhost:8080/irj/resources/com.sapportals.pdk.documentation.HowToDevelopMyPortalComponent/docs/JSP_Support.html
  • 8.  SAP AG 2002, Title of Presentation, Speaker Name 8 Using Java Server PagesUsing Java Server PagesUsing Java Server PagesUsing Java Server Pages ! JSPs & Java iView runtime ! JSPs & HTMLB ! Methods for JSP integration
  • 9.  SAP AG 2002, Title of Presentation, Speaker Name 9 JSPs & HTMLBJSPs & HTMLBJSPs & HTMLBJSPs & HTMLB .Java TextView t = new TextView(); t.setText("Hello World!"); JSP: <hbj:textView text="Hello World"/> Wrap components with custom JSP tags !
  • 10.  SAP AG 2002, Title of Presentation, Speaker Name 10 JSPs & HTMLBJSPs & HTMLBJSPs & HTMLBJSPs & HTMLB Important Stuff!!!! The physical location of the HTMLB tag library: " %TOMCAT_HOME% webappsirjserviceshtmlbtaglib Using the Taglib Provided by Portal services All JSP that are compiled into a Portal Component can use tag libraries provided by the PRT services (e.g. HTML-Business for Java (HTMLB)). " The tag library definition file must be referenced in the property file of the Portal Component. $ tagLib.value =/SERVICE/htmlb/taglib/htmlb.tld " Within the JSP file itself the tab library needs to be referenced $ At the beginning of the JSP file that is using the tag library the custom tag library definition property has to be declared: $ <%@ taglib uri="tagLib" prefix="hbj" %> Examples 1. Entries in property file default.properties to use the HTMLB service and tag library: 2. Beginning of JSP file that is using HTMLB tags
  • 11.  SAP AG 2002, Title of Presentation, Speaker Name 11 JSPs & HTMLBJSPs & HTMLBJSPs & HTMLBJSPs & HTMLB <%@taglib uri="tagLib" prefix="hbj" %> <hbj:content id="myContext" > <hbj:page title="Hello World"> <hbj:form> <hbj:textView id="welcome"> <% welcome.setText("Hello World"); %> </hbj:textView> </hbj:form> </hbj:page> </hbj:content> Hello worldHello worldHello worldHello world …………Using JSPsUsing JSPsUsing JSPsUsing JSPs
  • 12.  SAP AG 2002, Title of Presentation, Speaker Name 12 Using Java Server PagesUsing Java Server PagesUsing Java Server PagesUsing Java Server Pages ! JSPs & Java iView runtime ! JSPs & HTMLB ! Methods for JSP integration
  • 13.  SAP AG 2002, Title of Presentation, Speaker Name 13 Methods for JSP integrationMethods for JSP integrationMethods for JSP integrationMethods for JSP integration ! JSPDynpage ! JSPNative
  • 14.  SAP AG 2002, Title of Presentation, Speaker Name 14 JSPDynPageJSPDynPageJSPDynPageJSPDynPage ! JSPDynpage Model ! Usage of Beans ! Example
  • 15.  SAP AG 2002, Title of Presentation, Speaker Name 15 DynPage Extends PageProcessorComponent JSPDynPage ModelJSPDynPage ModelJSPDynPage ModelJSPDynPage Model AbstractPortalComponent implements IPortalComponent Interface public abstract class PageProcessorComponent extends AbstractPortalComponent PageProcessorComponent is the base class for Htmlb component that want to use the DynPage programming model within the Portal Runtime JSPDynPage is a special implementation to enable usage of a DynPage in combination with JSPs in the Portal environment. First step is to define a class that works as loader class - it inherits from the PageProcessorComponent. The created loader class executes the method getPage() and returns a unique value of the JSP DynPage AbstractPortalComponent Implements IPortalComponent Interface PageProcessorComponent Extends AbstractPortalComponent Introducing JSPDynPage Model JSPDynPage Extends DynPage
  • 16.  SAP AG 2002, Title of Presentation, Speaker Name 16 JSPDynpageJSPDynpageJSPDynpageJSPDynpage ModelModelModelModel Request doProcessAfterInput JSPDynPage PageProcessorComponent doInitialization doProcessBeforeOutput
  • 17.  SAP AG 2002, Title of Presentation, Speaker Name 17 JSPDynPageJSPDynPageJSPDynPageJSPDynPage ! JSPDynpage Model ! Usage of Beans ! Example
  • 18.  SAP AG 2002, Title of Presentation, Speaker Name 18 Usage of BeanUsage of BeanUsage of BeanUsage of Bean For complex applications, it is suitable to separate not only the logic from the view, but also the data from the logic. This leads to a Model-View-Controller architecture: JspDynPage (Controller) Data Bean (Model) JSP (View) Request Response
  • 19.  SAP AG 2002, Title of Presentation, Speaker Name 19 Usage of BeanUsage of BeanUsage of BeanUsage of Bean Bean The bean concept - reusable components that can be used in more than one software package - plays an important role in the portal component development. Portal components can use the beans to store and retrieve data. The JSP as well as the servlet (JSPDynPage, AbstractPortalComponent, DynPage, Native servlet) have read and write access to the bean so the bean can be used to transfer data between the JSP and the servlet. Bean %JSPDynPage and JSP data exchange using a Bean %A bean is used to get and set "dynamic" data. The JSPDynPage usually provides the bean with data and the JSP reads the data. The functionality of the basic example is extended by an input field that allows user input. The user input is stored in a bean and than displayed as text by a JSP program. Following steps are necessary %create a bean %initialize the bean %Access the bean in the JSP program (where bean data is required)
  • 20.  SAP AG 2002, Title of Presentation, Speaker Name 20 Usage of BeanUsage of BeanUsage of BeanUsage of Bean In a JSP page, one can access Java Bean objects using the tag <jsp:useBean id="object name" scope="application|session|reque st|page" class="class name" /> where " id is the name of the bean object in the compiled JSP " scope can be $ application -> the bean is stored in the associated component profile object $ session -> the bean is stored in the associated HttpSession or IPortalComponentSession object $ request -> the bean is stored in the associated HttpServletRequest object $ page -> the bean is stored in the associated javax.servlet.jsp.PageContext object " class is the fully qualified classname of the bean
  • 21.  SAP AG 2002, Title of Presentation, Speaker Name 21 JSPDynPageJSPDynPageJSPDynPageJSPDynPage ! JSPDynpage Model ! Usage of Beans ! Example
  • 22.  SAP AG 2002, Title of Presentation, Speaker Name 22 ExampleOneExampleOneExampleOneExampleOne Bean 2) OnSubmit 1) Initial form is displayed 3) Sends info to bean 4) Receives info from bean 5) Renders results
  • 23.  SAP AG 2002, Title of Presentation, Speaker Name 23 ExampleOneExampleOneExampleOneExampleOne Parts processForm.java (extends the JSPDynPage) " Supplies the logic and calls the required JSP file " Handles the Event " Populates the bean with user input Form.jsp " GUI Form for the end user to enter data Result.jsp " Retrieves the data from the bean " Displays the data DynPageNameBean.java " Allows to “Set” and “Get data
  • 24.  SAP AG 2002, Title of Presentation, Speaker Name 24 ExampleOneExampleOneExampleOneExampleOne Form.jsp Result.jsp processForm (Controller) DynPageNameBean
  • 25.  SAP AG 2002, Title of Presentation, Speaker Name 25 Writing the CodeWriting the CodeWriting the CodeWriting the Code Note the location of the JSPs
  • 26.  SAP AG 2002, Title of Presentation, Speaker Name 26 Writing the CodeWriting the CodeWriting the CodeWriting the Code Setting VariablesSetting VariablesSetting VariablesSetting Variables ; Variables defined to evaluate which JSP file to process Variables to store data
  • 27.  SAP AG 2002, Title of Presentation, Speaker Name 27 Writing the CodeWriting the CodeWriting the CodeWriting the Code doInitialization Sets the variable state to the value of INITITAL_STATE: Which had a static value of 0.
  • 28.  SAP AG 2002, Title of Presentation, Speaker Name 28 Writing the CodeWriting the CodeWriting the CodeWriting the Code doProcessBeforeOutput =INITIAL_STATE Default location: privatepagelet
  • 29.  SAP AG 2002, Title of Presentation, Speaker Name 29 Writing the CodeWriting the CodeWriting the CodeWriting the Code Form.JSP FirstName LastName Email
  • 30.  SAP AG 2002, Title of Presentation, Speaker Name 30 Writing the CodeWriting the CodeWriting the CodeWriting the Code HTMLB
  • 31.  SAP AG 2002, Title of Presentation, Speaker Name 31 Writing the CodeWriting the CodeWriting the CodeWriting the Code Button
  • 32.  SAP AG 2002, Title of Presentation, Speaker Name 32 Writing the CodeWriting the CodeWriting the CodeWriting the Code doProcessAfterInput 1 2 3 4
  • 33.  SAP AG 2002, Title of Presentation, Speaker Name 33 Writing the CodeWriting the CodeWriting the CodeWriting the Code doProcessBeforeOutput State=WELCOME_STATE
  • 34.  SAP AG 2002, Title of Presentation, Speaker Name 34 Writing the CodeWriting the CodeWriting the CodeWriting the Code Result.JSP
  • 35.  SAP AG 2002, Title of Presentation, Speaker Name 35 Writing the CodeWriting the CodeWriting the CodeWriting the Code The Bean Sent here after the processForm reads the data inputed by the use and extracted from the input fields. This stores the data until it is requested for either examination or output.
  • 36.  SAP AG 2002, Title of Presentation, Speaker Name 36 Writing the CodeWriting the CodeWriting the CodeWriting the Code Profile
  • 37.  SAP AG 2002, Title of Presentation, Speaker Name 37 ExampleOne Recap
  • 38.  SAP AG 2002, Title of Presentation, Speaker Name 38 Methods for JSP integrationMethods for JSP integrationMethods for JSP integrationMethods for JSP integration ! JSPDynpage ! JSPNative
  • 39.  SAP AG 2002, Title of Presentation, Speaker Name 39 JSPNativeJSPNativeJSPNativeJSPNative Profile ComponentType=jspnative JSP=Name of the JSP File tagLib=/SERVICE/htmlb/taglib/htmlb.tld ServicesReference=htmlb &JSPNative: A Portal Component is simply written as one JSP which is compiled to a Portal Component at runtime. Set the profile property ComponentType to jspnative In the .par file, the JSP should be located under privatejsp (If folder JSP does not exist previously, it needs to be created)
  • 40.  SAP AG 2002, Title of Presentation, Speaker Name 40 Using Java Server Pages Using Resources Unit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & Internationalization Internationalization Re-Using Resources & Classes
  • 41.  SAP AG 2002, Title of Presentation, Speaker Name 41 Using ResourcesUsing ResourcesUsing ResourcesUsing Resources Resources can either be basic resources like applets, scripts, images, static pages or more complex resources like xml files or even java properties files. If you want to use resources in your Portal component, you have to declare in your component where to find the resources with the help of methods from the IResource interface (Portal Runtime API) Here are some supported resource types and their default scopes & extensions : SCRIPT (Public) (.js) STATIC_PAGE (Public) (.html) APPLET (Public) IMAGE (Public) (.gif) JSP (Private) (.jsp) XML (Private) (.xml) PROFILE (Private) (.properties) How to use resources: Fetch the resource from the IPortalComponentRequest interface. This returns an Iresource object. Now you can add it to the response by calling the IPortalComponentResponse.addResource(IResource) method.
  • 42.  SAP AG 2002, Title of Presentation, Speaker Name 42 Using ResourcesUsing ResourcesUsing ResourcesUsing Resources Recommended file structure for Resources: applet* * Indicates that folder names can be custom names Where are they stored when .par file is deployed? Private: %TOMCAT_HOME%webappsirjWEB-INFpluginsportalresources<.par name> Public: %TOMCAT_HOME%webappsirjresources<.par name> … Private Public images* html* scripts* profiles jsp (jspnative approach) pagelet (JspDynpage approach) xml* … Generated Web URL for Public Resources: http://localhost:8080/irj/resources/<par file name> /<Folder Name>/<File name> You can use any folder names for those under the public folder. The Generated web url is purely for your information, you don’t need to know this as you will be using the iresource methods as you will see in the following slides.
  • 43.  SAP AG 2002, Title of Presentation, Speaker Name 43 Using ResourcesUsing ResourcesUsing ResourcesUsing Resources ! Using Images & HTML Pages ! Using JavaScript ! Using Applets ! JSP again!
  • 44.  SAP AG 2002, Title of Presentation, Speaker Name 44 Images: Under the Public folder, place your images (.gif) in any folder. Let us say we have an image under the following location: public images garfield.gif How to access it? IResource garfield = componentrequest.getResource(IResource.IMAGE,"images/garfield.gif"); or IResource garfield = componentrequest.getResource(IResource.IMAGE,"images/garfield"); //since default extension is .gif componentresponse.addResource(garfield); or Image logo; logo=new Image(garfield.getResourceInformation().getURL(req),"Logo"); myForm.addComponent(logo); HTML: Under the Public folder, place your HTML (.html) in any folder. Let us say we have an HTML Page under the following location: public html simple.html Similarly, IResource myhtml= componentrequest.getResource(IResource.STATIC_PAGE,"html/simple.html"); componentresponse.addResource(myhtml); Using Images & HTML PagesUsing Images & HTML PagesUsing Images & HTML PagesUsing Images & HTML Pages
  • 45.  SAP AG 2002, Title of Presentation, Speaker Name 45 Using ResourcesUsing ResourcesUsing ResourcesUsing Resources ! Using Images & HTML Pages ! Using JavaScript ! Using Applets ! JSP again!
  • 46.  SAP AG 2002, Title of Presentation, Speaker Name 46 Using JavaScriptUsing JavaScriptUsing JavaScriptUsing JavaScript Some Methods: 1. Under the Public folder, create a folder say, scripts and place your .js file. 2. Create an HTMLB fragment and add to the class 3. Use <script></script> tags in JSP Let us say we have a .js file named myscript.js containing a function runme() IResource jsResource = componentRequest.getResource(IResource.SCRIPT, "script/myscript.js"); componentresponse.addResource(jsResource); 1. .js file in scripts folder
  • 47.  SAP AG 2002, Title of Presentation, Speaker Name 47 Using JavaScriptUsing JavaScriptUsing JavaScriptUsing JavaScript 2. Create an HTMLFragment element (HTMLB element) String frag= new String(" <SCRIPT language=JavaScript>"); frag = frag + " function runme(siteName,userName,pwd){"; frag = frag+… frag = frag + "}"; frag = frag + "</SCRIPT>"; HTMLFragment hf=new HTMLFragment(frag);//Special container for raw HTML. Note that using this class //might cause Browser dependencies myForm.addComponent(hf); 3. Use <script> tags in JSP <script> function runme(){ … } </script>
  • 48.  SAP AG 2002, Title of Presentation, Speaker Name 48 Using JavaScriptUsing JavaScriptUsing JavaScriptUsing JavaScript If you want to access HTMLB elements via JavaScript, we recommend that you create you HTMLB elements in JSP and use Method 3 How to invoke the JavaScript function? Use htmlb elements that have onclient… methods- Button, Link, Drop Down List box Mybutton.setOnClientClick(“runme()“) or via jsp <hbj:button id=“Mybutton" text="Click!" onClientClick=“runme()"/> Or <script>runme();</script>
  • 49.  SAP AG 2002, Title of Presentation, Speaker Name 49 Using JavaScriptUsing JavaScriptUsing JavaScriptUsing JavaScript How to access HTMLB elements? HTMLB provides access to the HTML IDs that are generated during runtime. After retrieving the IDs, you can generate your JavaScript by setting the correct IDs at runtime. % Declare String variables at the start of the JSP that will hold the HTML IDs of the components you wish to access from JavaScript % Use a method of the HTMLB com.sapportals.htmlb.rendering.PageContext class: pageContext.getParamIdForComponent(com.sapportals.htmlb.Component component). This method returns a String, and this String is the generated ID value for the given component. % Write the script and use this generated ID to identify you HTMLB element % Invoke the script Example: <%String compid="";%> <hbj:inputField id="InputName" type="string" maxlength="100"> <% compid=myContext.getParamIdForComponent(InputName);%> </hbj:inputField> <hbj:button id="button1" text="Type&Click!" onClientClick="runme()"/> Needs to be placed before </hbj:unputField>, to access this inputField component <script> function runme() { var myval=document.getElementById('<%=compid%>').value; alert("You typed: "+myval); } </script>
  • 50.  SAP AG 2002, Title of Presentation, Speaker Name 50 Using ResourcesUsing ResourcesUsing ResourcesUsing Resources ! Using Images & HTML Pages ! Using JavaScript ! Using Applets ! JSP again!
  • 51.  SAP AG 2002, Title of Presentation, Speaker Name 51 Using AppletsUsing AppletsUsing AppletsUsing Applets How to access it? IResource myapplet= req.getResource(IResource.APPLET,"applet/"); String myurl=myapplet.getResourceInformation().getURL(req); componentresponse.write("<applet name="ChompText" archive="ChompText.zip" codebase=""+myurl+"" code="ChompText.class" width=250 height=55>"); componentresponse.write("<param name="text" value="Java Boutique">"); componentresponse.write("<param name="textcolor" value="0000FF">"); componentresponse.write("<param name="bgcolor" value="FFFFFF">"); componentresponse.write("</Applet>"); Under the Public folder, place your applet classes (..jar, .zip) in any folder. Let us say we have an applet ChompText.zip under the following location: public applet ChompText.zip zz
  • 52.  SAP AG 2002, Title of Presentation, Speaker Name 52 Using ResourcesUsing ResourcesUsing ResourcesUsing Resources ! Using Images & HTML Pages ! Using JavaScript ! Using Applets ! JSP again!
  • 53.  SAP AG 2002, Title of Presentation, Speaker Name 53 Under the Private folder, place your JSPs (.jsp) in any folder. Let us say we have a jsp under the following location: private jsp private.jsp How to access it? IResource myjsp= componentrequest.getResource(IResource.JSP,"jsp/private.jsp"); componentrequest.dispatchRequest(myjsp,componentresponse); or componentresponse.addResource(myjsp); Using JSPsUsing JSPsUsing JSPsUsing JSPs Note: JSPs as Web URLS is Not reccommended
  • 54.  SAP AG 2002, Title of Presentation, Speaker Name 54 Using Java Server Pages Using Resources Unit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & Internationalization Internationalization Re-Using Resources & Classes
  • 55.  SAP AG 2002, Title of Presentation, Speaker Name 55 ReReReRe----Using Resources & ClassesUsing Resources & ClassesUsing Resources & ClassesUsing Resources & Classes ! Re-Using Resources ! Re-Using Classes
  • 56.  SAP AG 2002, Title of Presentation, Speaker Name 56 ReReReRe----Using ResourcesUsing ResourcesUsing ResourcesUsing Resources You can reuse the resources from an existing .par file. You need to know the name of the .par file that contains the resources. You can then get the resource from the componentrequest Example: IResource myimage= componentrequest.getResource(“SimpleExample.default",IResource.IMAGE,"images/SAPPortals_opt2.gif"); componentresponse.addResource(myimage);
  • 57.  SAP AG 2002, Title of Presentation, Speaker Name 57 ReReReRe----Using Resources & ClassesUsing Resources & ClassesUsing Resources & ClassesUsing Resources & Classes ! Re-Using Resources ! Re-Using Classes
  • 58.  SAP AG 2002, Title of Presentation, Speaker Name 58 ReReReRe----Using ClassesUsing ClassesUsing ClassesUsing Classes How to re-use existing classes / External Libraries? Method One You have some classes (.jar file) in the lib folder of a .par file (A) that you want to use in another .par file (B) You don't have to package the .jars again in the lib folder. In the default.properties of the .par file (A) containing the .jar files, make the following entry: SharingAccess=shared This determines access to the package using the SharingReference property. In the default.properties of the .par file (B), make the following entry: SharingReference= .par file (A) name This declares references to par file (A). This creates a sharing dependency, which requires that the .par file (A) be uploaded beforehand in the PDK/Portal. For more than one reference, the list of package names must be separated by a comma.
  • 59.  SAP AG 2002, Title of Presentation, Speaker Name 59 ReReReRe----Using ClassesUsing ClassesUsing ClassesUsing Classes Some More Alternatives How to re-use existing classes? Method Two 'Package as a Portal Service (Not in the scope of this class) Method Three 'Include in class-path (Not Reccomended) In the PDK, you can copy the .jar files to <Tomcat_home>libapps. This will be loaded by the Portal runtime. Migration to Enterprise Portal: Upload the .par file and create Java iView based on Master. Make sure you add the External libraries to the Servlet Engine's class-path Tip for SAPJ2EE Engine Copy the .jar files to <SAPJ2EE_Home>aloneadditional-lib. Use the Config tool, Click on "alone" and edit the Java parameters. Example: -classpath".;.system-libboot.jar;.system-libjaas.jar;.additional-libyourexternallib.jar;" This is a good step to follow if you are using any of the libraries in <SAPJ2EE_Home>aloneadditional-lib. Disadvantages: &Extra steps to be performed while migrating to other Enterprise Portals &Classes are visible for all iViews &Version conflicts can occur
  • 60.  SAP AG 2002, Title of Presentation, Speaker Name 60 Using Java Server Pages Using Resources Unit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & InternationalizationUnit: JSPs, Resources & Internationalization Internationalization Re-Using Resources & Classes
  • 61.  SAP AG 2002, Title of Presentation, Speaker Name 61 InternationalizationInternationalizationInternationalizationInternationalization ! Methodology ! Example
  • 62.  SAP AG 2002, Title of Presentation, Speaker Name 62 MethodologyMethodologyMethodologyMethodology Language support for Java iViews is by use of Java resource bundles. The Java iView runtime provides API that allow an iView to communicate with the resource bundle containing the text to display in the iView. Know the ISO88559-1 Country Codes for language wanted to translate " Know the languages Enterprise Portal supported Localization files need to exist under the folder private/classes For each language wanted to translate a localization_xx.properties file needs to be created " German: localization_de.properties " Spanish: localization_es.properties " Default Language: localization.properties If you want to name your translation files something else other than localization_xx.properties, there must be a reference to it in the default.properties file. Example: ExampleOne_de.properties, ExampleOne_es.properties Specify localization file name in default.properties ResourceBundleName=ExampleOne
  • 63.  SAP AG 2002, Title of Presentation, Speaker Name 63 MethodologyMethodologyMethodologyMethodology For Translating Strings Access the language resource in your code <% Import java.util.ResourceBundle; %> <% ResourceBundle res = componentRequest.getResourceBundle();%> <%Send_Button.setText(res.getString(“button.send"));%> Sample Entry in localization_de.properties button.send=Senden For translating Personalization Parameter Names use the Description attribute Any String
  • 64.  SAP AG 2002, Title of Presentation, Speaker Name 64 Language SettingsLanguage SettingsLanguage SettingsLanguage Settings To run the iView in a different language in the PDK, the following needs to be done Locate the file workplace.properties <Tomcat_Home>webappsirjWEB-INFpluginsportalsystemproperties Look for request.mandatorylanguage=en Remove it this entry (or comment #) Now restart tomcat. Change the Language for Internet Explorer (or) " The language has to be one that is supported by the portal Change the user locale in Kmusers.properties Precedence 1. Locale of the PDK (if specified in workplace.properties) 2. Locale of the user (if specified in kMusers.properties) 3. Locale of the client ( [i.e. if set up in (e.g.) IE under Tools/Internet Options/Languages...])
  • 65.  SAP AG 2002, Title of Presentation, Speaker Name 65 Language SettingsLanguage SettingsLanguage SettingsLanguage Settings Forcing a language in PDK • If the desired effect is for the PDK to be displayed in a particular language regardless of browser settings or user setting then the • Workplace.properties • request.mandatorylanguage=ISO Language requirement If the entry in workplace.properties is removed: • Language of Browser • PDK is displayed initially with this language • If language not supported, PDK defaults to English • User Locale • Language changes based on logged on user’s locale in KMusers.properties • If no user locale is specified, then browser language is displayed Example Browser Setting = Spanish (es) User Locale= German (de) Results: " PDK HomePage= Spanish User logs on " PDK = German " IView = German (If no specific localization file exists for german, the iView runs in the default localization)
  • 66.  SAP AG 2002, Title of Presentation, Speaker Name 66 Forcing PDK Mandatory LanguageForcing PDK Mandatory LanguageForcing PDK Mandatory LanguageForcing PDK Mandatory Language To change the mandatory language for the PDK, this needs to be set. Note! It takes precedence If you want the PDK to render content in the language of the browser or the language of the user, the variable described here needs to be commented out Locate the file workplace.properties <Tomcat_Home>webappsirjWEB-INFpluginsportalsystemproperties
  • 67.  SAP AG 2002, Title of Presentation, Speaker Name 67 User LocaleUser LocaleUser LocaleUser Locale <Tomcat_Home>webappsirjWEB-INFpluginsportalservicesusermanagementdata In the kmusers.properties file there is a list of the PDK users
  • 68.  SAP AG 2002, Title of Presentation, Speaker Name 68 Language Setting in IELanguage Setting in IELanguage Setting in IELanguage Setting in IE
  • 69.  SAP AG 2002, Title of Presentation, Speaker Name 69 InternationalizationInternationalizationInternationalizationInternationalization ! Methodology ! Example
  • 70.  SAP AG 2002, Title of Presentation, Speaker Name 70 ExampleExampleExampleExample Internationalize ExampleOne " The languages we will use are Spanish, German, English (default) " We will “Internationalize” the initial form Form.jsp. $ Labels $ Text for the button
  • 71.  SAP AG 2002, Title of Presentation, Speaker Name 71 ExampleOneExampleOneExampleOneExampleOne Form.jsp
  • 72.  SAP AG 2002, Title of Presentation, Speaker Name 72 “Internationalize” Form.jsp:“Internationalize” Form.jsp:“Internationalize” Form.jsp:“Internationalize” Form.jsp: Labels Use label_FirstName.setText(res.getString(“label.firstName”)) But you need to place it before the closing tag of <hbj: label…> This will be the string we will use in the localization file
  • 73.  SAP AG 2002, Title of Presentation, Speaker Name 73 “Internationalize” Form.jsp:“Internationalize” Form.jsp:“Internationalize” Form.jsp:“Internationalize” Form.jsp: Button
  • 74.  SAP AG 2002, Title of Presentation, Speaker Name 74 Localization FilesLocalization FilesLocalization FilesLocalization Files " First we need to create a localization file (for a default language, say English) named localization.properties " Create the localization.properties, localization_xx.properties, under the src folder of project. When you compile/create .par, the localization file will move to the right location under private/classes.
  • 75.  SAP AG 2002, Title of Presentation, Speaker Name 75 Localization FilesLocalization FilesLocalization FilesLocalization Files localization.properties
  • 76.  SAP AG 2002, Title of Presentation, Speaker Name 76 Localization FilesLocalization FilesLocalization FilesLocalization Files In order to access a String in German, Spanish and a default representation (say English), you would have the following structure: label.firstName=Given Name label.lastName=Family Name label.email= Rapid Mail button.send=Fire it off! label.firstName=Vorname label.lastName=Nachname label.email= e-mail Adresse button.send=Senden label.firstName=il primo nome label.lastName=l'ultimo nome label.email= correo electrónico button.send=mande
  • 77.  SAP AG 2002, Title of Presentation, Speaker Name 77 SummarySummarySummarySummary You now know: ! Different methods to Integrate JSPs ! How to use resources such as JavaScripts, HTML & Applets ! How to re-use resources and classes ! How to use Language resource bundles to perform Internationalization
  • 78.  SAP AG 2002, Title of Presentation, Speaker Name 78 " No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. " Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. " Microsoft®, WINDOWS®, NT®, EXCEL®, Word®, PowerPoint® and SQL Server® are registered trademarks of Microsoft Corporation. " IBM®, DB2®, DB2 Universal Database, OS/2®, Parallel Sysplex®, MVS/ESA, AIX®, S/390®, AS/400®, OS/390®, OS/400®, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere®, Netfinity®, Tivoli®, Informix and Informix® Dynamic ServerTM are trademarks of IBM Corporation in USA and/or other countries. " ORACLE® is a registered trademark of ORACLE Corporation. " UNIX®, X/Open®, OSF/1®, and Motif® are registered trademarks of the Open Group. " Citrix®, the Citrix logo, ICA®, Program Neighborhood®, MetaFrame®, WinFrame®, VideoFrame®, MultiWin® and other Citrix product names referenced herein are trademarks of Citrix Systems, Inc. " HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology. " JAVA® is a registered trademark of Sun Microsystems, Inc. " JAVASCRIPT® is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. " MarketSet and Enterprise Buyer are jointly owned trademarks of SAP AG and Commerce One. " SAP, SAP Logo, R/2, R/3, mySAP, mySAP.com and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are trademarks of their respective companies. Copyright 2002 SAP AG. All Rights Reserved