Monday, December 26, 2011

ATG Migration Issues: JSP-based Applications


JSP-based Applications
Because JSP-based applications rely on the application server’s JSP compiler, any differences between DAS’s JSP compiler and the JSP compiler on the application server you are migrating to must be taken into account. This section describes some practices to follow in your JSPs to ensure they are portable.
Using Java Expressions in Pages
·                     On WebLogic, the request object in a JSP is a standard HttpServletRequest, not a DynamoHttpServletRequest. To access theDynamoHttpServletRequest object, use ServletUtil.getDynamoRequest(ServletRequest).
·                     On DAS, the atg.servlet package is imported by default in JSP pages. On other application servers, you must explicitly import the atg.servletpackage in any page that uses classes from that package.
Using the DSP Tag Library
To learn about the DSP tag library, see the ATG Page Developer’s Guide.
·                     Each JSP that uses the DSP tag library must enclose its contents in beginning and ending dsp:page tags, like this:
<dsp:page>
... body of page ...
</dsp:page>
·                     In pages that use the DSP tag library, you should avoid using standard JSP tags and instead use DSP tags wherever possible. The JSP tags do not work reliably with the DSP tag library, and the DSP tags provide additional features, such as support for the passing of object parameters between pages. In particular, use dsp:include rather than jsp:include or jsp:forward, and use dsp:param rather than jsp:param.
·                     Do not use value="param:paramName" to get the value of a parameter. Instead use dsp:getvalueof to expose a scripting variable.
JSP Syntax
·                     Nested pairs of quotation marks must alternate between single and double quotes. For example, the following works on DAS, but not on some application servers:
<dsp:param name="<%="abc"%>" value="17">
Instead, use:
<dsp:param name='<%="abc"%>' value="17">
·                     Use proper syntax for concatenating text strings. For example, the following works on DAS, but not on some application servers:
<dsp:param name="xxx"<%= "yyy" %> value="12">
Instead, use:
<dsp:param name='<%= "xxx" + "yyy" %>' value="12">
Servlet Pipeline
When an ATG application processes a request for a JSP that includes the DSP tag library, it invokes a servlet pipeline whose Nucleus component path is/atg/dynamo/servlet/dafpipeline. The DAF pipeline has fewer servlets than the DAS servlet pipeline, because it is not doing any request dispatching, mime typing, or file finding in normal operation. These operations are handled by the application server rather than by the ATG platform.
If your application adds any servlets to the DAS servlet pipeline, you will need to add these servlets to the DAF pipeline to run your application on another application server. You create a new instance of your servlet (since each pipeline servlet can be in only a single pipeline), and then insert it in the DAF servlet pipeline at the appropriate place.
There are some differences between how the DAF servlet pipeline and the DAS servlet pipeline work. For information about these differences, see Request Handling with Servlet Pipelines in the ATG Programming Guide.
Other Issues
·                     Use javax.servlet.http.HttpSession, not atg.servlet.sessiontracking.SessionData, as the class for your session.
·                     On DAS, you can use ATG’s EncodingTyper component to specify the encoding of your JSPs. On other application servers, you must specify the encoding using the contentType attribute of the JSP page directive, which is the standard mechanism for defining encodings in a JSP. Note, however, that may still need to configure the EncodingTyper to specify the encoding of posted data in forms. See the ATG Programming Guide for more information.
·                     Do not use request.getParameter("name") to return parameters set using the dsp:param tag. Instead, use thegetDynamoRequest(request).getParameter("name") method of the atg.servlet.ServletUtil class to retrieve these parameters. You can of course assume that these parameters are visible to any tags in the DSP tag library that take parameter names. Your application server’sHttpServletRequest implementation will return only those parameters set through standard mechanisms, such as query arguments, post parameters, and parameters set using the jsp:param tag.
·                     Do not use HttpServletRequest.getSession() to get a session object. Instead, use the getDynamoRequest(request).getSession() method of theatg.servlet.ServletUtil class.

No comments:

Popular Posts