|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.iplanet.portalserver.providers.ProviderAdapter
|
+--com.iplanet.portalserver.providers.ProfileProviderAdapter
|
+--com.iplanet.portalserver.providers.jsp.JSPProvider
A JSPProvider is a content provider that can use JavaServer Pages
(JSPs) to create the content for a channel on the desktop.
A provider is responsible for providing the HTML content for a channel as well as defining the various attributes for a channel (title, description, etc.) and optionally implementing edit functionality (one or more edit pages and the logic for processing changes to the channel).
JavaServer Pages is a alternative technology for defining web pages that provides several advantages over Java servlet development. These same advantages apply to the idea of developing Portal Server desktop channels using JavaServer Pages. Several key advantages include:
JSPProvider can update a JSP without restarting the web
server.JSPProvider extends the
ProfileProviderAdapter class so it supports setting of
various other attributes for the channel by using the profile
service.JSPProvider channels are typically created by using the channel
wizard in the administration console to add a JSP channel to the
desktop. Along with the attributes that are common to all
providers that are based on ProfileProviderAdapter,
JSPProvider supports the following unique attributes:
JSPProvider shows
exceptions generated while processing the JSP as the channel output
for the getContent and getEdit methods.
This can be useful during development.
The contentPage JSP generates the HTML content for the channel. The generated HTML must contain only those tags that are appropriate for display within a channel. The JSP has access to iPS platform services via the mechanisms described below.
The editPage JSP generates the internals for the edit form that is displayed when the user clicks the Edit button for the channel. This page is optional. As with the contentPage JSP, the JSP has access to iPS platform services.
The contentPage and editPage JSPs can be used in various
combinations. For example, a JSP could be used to generate
the content while the edit page could be generated using Java code
in a class that extends JSPProvider.
There are several options for handling the processing of an edit form for a JSP-based provider. Typically, processing of the edit form consists of Java code that checks validity of the form entry and updates user preferences for the channel. The result is either a redisplay of the desktop (in the case of success) or a redisplay of the edit page, possibly with some error information for the user (in the case of a failure). To handle the processing of an edit form, the JSP-based provider has the following options:
processEdit method for the provider returns null, which causes a
redisplay of the desktop.response.sendRedirect. In this case, the
processEdit method for the provider returns the value
of the redirect.File Searching
When specifying a JSP in one of the JSP attributes, the path
name is interpreted relative to the desktop template directory for
the user using the same algorithm as for other desktop templates
including inclusion of the desktop type and locale settings, channelName and the
clientPath. For example, if the user's locale is de_DE, desktop
type is SunBlue, channel name is myChan, clientPath is wml/nokia
and a JSP attribute is set to chan.jsp, JSPProvider
searches for the following JSP files:
/etc/opt/SUNWips/desktop/SunBlue_de_DE/myChan/wml/nokia/chan.jsp
/etc/opt/SUNWips/desktop/SunBlue_de_DE/myChan/wml/chan.jsp
/etc/opt/SUNWips/desktop/SunBlue_de_DE/myChan/chan.jsp
/etc/opt/SUNWips/desktop/SunBlue_de_DE/chan.jsp
/etc/opt/SUNWips/desktop/SunBlue/myChan/wml/nokia/chan.jsp
/etc/opt/SUNWips/desktop/SunBlue/myChan/wml/chan.jsp
/etc/opt/SUNWips/desktop/SunBlue/myChan/chan.jsp
/etc/opt/SUNWips/desktop/SunBlue/chan.jsp
/etc/opt/SUNWips/desktop/default_de_DE/myChan/wml/nokia/chan.jsp
/etc/opt/SUNWips/desktop/default_de_DE/myChan/wml/chan.jsp
/etc/opt/SUNWips/desktop/default_de_DE/myChan/chan.jsp
/etc/opt/SUNWips/desktop/default_de_DE/chan.jsp
/etc/opt/SUNWips/desktop/default/myChan/wml/nokia/chan.jsp
/etc/opt/SUNWips/desktop/default/myChan/wml/chan.jsp
/etc/opt/SUNWips/desktop/default/myChan/chan.jsp
/etc/opt/SUNWips/desktop/default/chan.jsp
The root of the search directory (/etc/opt/SUNWips/desktop/) can
be changed by modifying the ips.jsp.rootdir property
in the /etc/opt/SUNWips/platform.conf file.
A JSP-based provider may need access to service APIs that are provided by the Portal Server platform. A Java-based provider accesses these services by either using Provider API methods such as ProfileProviderAdapter.getProperty or by invoking iPS APIs directly Examples (with iPS APIs) include:
ProfileProviderAdapter getProperty methods)com.iplanet.portalserver.logging.* classes)Provider.init Session argument)com.iplanet.portalserver.util.Debug class)Typically a JSP-based provider consists of one or more JSP
files, beans or other Java classes that implement business logic,
and possibly a Java class that extends JSPProvider. Access to
iPS services is needed in all of these places. A Java class
that extends JSPProvider already has access to all of the APIs, so
that case is handled. For all other cases,
JSPProvider provides the JSPProvider
pageContext attribute for the JSP and other supporting
classes to access the iPS services.
Every JSP has access to several implicit objects. One of
these, called pageContext, represents the context
within which the page executes. The
pageContext.getAttribute method allows an arbitrary
object to be retrieved from the pageContext. The
JSPProvider defines a JSPProvider attribute
that provides access to the provider object that is executing the
JSP. This may be a JSPProvider object or a class that
is extended from JSPProvider.
For example, a scriptlet that would access a user profile
attribute using this API would be:
<%@ page import="com.iplanet.portalserver.providers.jsp.*" %>
<%
JSPProvider p = (JSPProvider)pageContext.getAttribute("JSPProvider");
%>
Value of myattr is <%= p.getStringProperty("myattr", "default value") %>
This JSP would display the value of the myattr attribute from the user's profile.
Once the JSP has access to the provider object, it can use methods in the JSPProvider class to access iPS services such as the session, or it can pass this object to other objects so that they can access iPS services.
JSP Engine
The JSP engine used by JSPProvider supports the
same set of JSP features as is supported by the iPlanet Web Server 4.1
that is included with Portal Server. This is the Servlet 1.1
specification without the following features:
Any classes or beans that are accessed by JSPs must be placed into
the class path of the web server. Typically, this is most easily
accomplished by putting the class files into the appropriate
package directory under the /opt/SUNWips/lib
directory.
Each JSP is compiled by the JSP engine
into a Java file and then the Java file is compiled by the JDK into
class files. These files are saved in a scratch directory that is
/var/opt/SUNWips/tmp by default. This default can be changed by
editing the ips.jsp.scratchdir property in the
/etc/opt/SUNWips/platform.conf file.
Troubleshooting
During development of JSP-based channels, there are several techniques available for debugging problems.
The showExceptions attribute can be turned on for a
channel on using the administration console. This will cause
exception messages to be displayed in the user desktop for the
getContent and getEdit methods.
Error messages from JSPProvider are printed in
either the iwtProvider or iwtDesktop
debug files in /var/opt/SUNWips/debug. If the
showExceptions attribute is turned off, this is where
to look for exception messages.
When the JSP file is changed on disk, the JSP is automatically
recompiled and reloaded without restarting the web server or
logging out and logging back in. However, as with other channels
that use ProfileProviderAdapter, user attributes are
not reread unless you logout and log back in.
JSP are compiled into Java files and the output is put into the scratch directory. Sometimes looking at the Java code can reveal problems in the JSP.
Provider,
ProfileProviderAdapter| Constructor Summary | |
JSPProvider()
Construct a JSPProvider. |
|
| Method Summary | |
java.lang.StringBuffer |
getContent(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Get the provider's content by executing a JSP. |
java.lang.StringBuffer |
getContent(java.util.Map m)
Get the provider's content page by executing a JSP. |
java.lang.StringBuffer |
getEdit(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Get the provider's edit page by executing a JSP. |
java.lang.StringBuffer |
getEdit(java.util.Map m)
Get the provider's edit page by executing a JSP. |
void |
init(java.lang.String n,
Session s)
Initialize the JSPProvider. |
java.net.URL |
processEdit(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Perform the provider's edit page processing by executing a JSP. |
java.net.URL |
processEdit(java.util.Map m)
Perform the provider's edit page processing by executing a JSP. |
| Methods inherited from class com.iplanet.portalserver.providers.ProfileProviderAdapter |
getBackgroundColor,
getColumn,
getDescription,
getEditType,
getHelp,
getListProperty,
getListProperty,
getRefreshTime,
getResourceBundle,
getRow,
getStringProperty,
getStringProperty,
getTitle,
getWidth,
hasBorder,
hasFrame,
hasHelp,
isAllowed,
isAllowed,
isAllowed,
isAllowed,
isDetachable,
isDetached,
isEditable,
isMinimizable,
isMinimized,
isMovable,
isRemovable,
load,
loadProperties,
setColumn,
setDetached,
setListProperty,
setListProperty,
setLocalListProperty,
setLocalListProperty,
setLocalStringProperty,
setLocalStringProperty,
setMinimized,
setRow,
setStringProperty,
setStringProperty,
store |
| Methods inherited from class com.iplanet.portalserver.providers.ProviderAdapter |
getName,
getSession,
isPresentable |
| Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public JSPProvider()
| Method Detail |
public void init(java.lang.String n,
Session s)
throws ProviderException
init() call
must always have
super.init() as the first statement
executed.n - The unique indentifying name for this channel.s - The user's session.Provider.init(java.lang.String, com.iplanet.portalserver.session.Session)
public java.lang.StringBuffer getContent(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws ProviderException
contentPage attribute has a value, it is
used as the name of a JSP to execute per the search algorithm
defined above. The body of the response is returned as the
value for the method. If the contentPage attribute
is blank, the superclass method is called.
The following values from the request are passed on to the JSP servlet:
request - An HttpServletRequest that contains information related to this
request for content.response - An HttpServletResponse that allows the provider to influence the
overall response for the desktop page (besides generating the content).ProfileProviderAdapter.getContent(java.util.Map)
public java.lang.StringBuffer getContent(java.util.Map m)
throws ProviderException
getContent method
except that cookies from the request are not passed to the JSP.
m - A key-value mapping of GET parameters passed to the desktop
by the requesting browser.
public java.lang.StringBuffer getEdit(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws ProviderException
editPage attribute has a value, it is
used as the name of a JSP to execute per the search algorithm
defined above. The body of the response is returned as the
value for the method. If the editPage attribute
is blank, the superclass method is called.
The following values from the request are passed on to the JSP servlet:
request - An HttpServletRequest that contains information related to this
request for content.response - An HttpServletResponse that allows the provider to influence the
overall response for the desktop page (besides generating the content).ProfileProviderAdapter.getEdit(java.util.Map)
public java.lang.StringBuffer getEdit(java.util.Map m)
throws ProviderException
getEdit method
except that cookies from the request are not passed to the JSP.
m - A key-value mapping of GET parameters passed to the desktop
by the requesting browser.
public java.net.URL processEdit(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws ProviderException
processPage attribute has a value, it is
used as the name of a JSP to execute per the search algorithm
defined above. If the response from the JSP is a redirect, the
redirect location is returned as a URL. If the response from
the JSP is a normal OK response (200), null is returned
resulting in a redisplay of the desktop. Otherwise and
exception is thrown. If the processPage attribute
is blank, the superclass method is called.
The following values from the request are passed on to the JSP servlet:
request - An HttpServletRequest that contains information related to this
request for content.response - An HttpServletResponse that allows the provider to influence the
overall response for the desktop page (besides generating the content).Provider.processEdit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
public java.net.URL processEdit(java.util.Map m)
throws ProviderException
processEdit method
except that cookies from the request are not passed to the JSP.m - A key-value mapping of GET parameters passed to the desktop
by the requesting browser.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||