ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzatz_5.4.0.1/51/migration/wappmig.htm

87 lines
7.6 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
<title>Migrate Web applications</title>
</head>
<BODY>
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h3><a name="wappmig"></a>Migrate Web applications</h3>
<p>While version 2.3 of the servlet specification and version 1.2 of the JavaServer Pages (JSP) specification are supported by WebSphere Application Server Express, versions 1.1 and 1.2 of the JavaServer Pages (JSP) specification are compatible and the difference between versions 2.2 and 2.3 of the servlet specification are minor. There are behavioral differences between the Java 2 Enterprise Edition (J2EE) 1.2 and 1.3 specifications.</p>
<p><strong>Servlet migration issues</strong></p>
<p>Servlet migration might be a concern for your application if it has these characteristics:</p>
<ul>
<li>It extends a PageListServlet that relies on configuration information in the servlet configuration XML file.</li>
<li>It uses a servlet to generate HTML output.</li>
<li>It calls the response.sendRedirect() method for a servlet by using the encodeRedirectURL function or by running it within a non-context root.</li>
<li>URIs at WebSphere Application Server - Express are case sensitive when handled by the file serving servlet. That is, when a request is sent to WebSphere Application Server to serve a file, the filename as it exists in the file system must match the case as is specified on the URI. This is also true starting with WebSphere Application Server Version 3.5.6 and beyond. If you are migrating a Web application from WebSphere Application Server 3.5.5 (or earlier), you need to ensure your Web applications use proper case when referencing file served files.</li>
<li><p>It is migrated from WebSphere Application Server Version 3.5, and it uses ServletContext attributes. Such attributes are accessed via the ServletContext.getAttribute() API during servlet execution. Websphere Application Server Version 3.5 provided these ways of setting ServletContext attributes:</p>
<p>
<ul>
<li>Using the ServletContext.setAttribute( ) - a runtime servlet API available at V2.1 and v2.2.</li>
<li>By configuring at the administrative console by clicking on a the Advanced tab for a web application and updating the name and value pair for the Attributes field. Such attributes are set at application server or web application startup. </li>
</ul>
</p>
<p>The second method of setting ServletContext methods is no longer available at WebSphere Application Server - Express, thus attributes can only be be set during servlet runtime using ServletContext.setAttribute( ) - the first method above. If your web application at Version 3.5 relied on setting ServletContext attributes using the second method, you should convert over to use getInitParameter( ) and getInitParameterNames( ), which are new servlet APIs as of v2.2.</p>
<p>The other internal servlets that are affected by the WebSphere Application Server - Express package name change are DefaultErrorReporter and AutoInvoker. Use the WebSphere Application Server - Express package name, com.ibm.ws.webcontainer.servlet.DefaultErrorReporter and com.ibm.ws.webcontainer.servlet.AutoInvoker for these servlets.</p>
</li>
</ul>
<p><strong>Web application migration tips</strong></p>
<p>Some tips for migrating your Web applications include the following:</p>
<ul>
<li><p>Set a content type if your servlet generates HTML output.</p>
<p>The default behavior of the Web container changed in WebSphere Application Server - Express. If the servlet developer does not specify a content type in the servlet then the container is forbidden to set one automatically. Without an explicit content type setting, the content type is set to <tt>null</tt>. The Netscape browser displays HTML source as plain text with a null content type setting.</p>
<p>To resolve this problem, do one of the following:</p>
<p>
<ul>
<li>Explicitly set a content type in your servlet.</li>
<li>Open the WAR file and enable the autoResponseEncoding static file setting.</li>
</ul>
</p>
</li>
<li><p>Set the Java environment variable, com.ibm.websphere.sendredirect.compatibility, to <tt>true</tt> if you want your URLs interpreted relative to the application root.</p></li>
<li><p>Import your classes if your application uses unnamed packages. According to the JSP 1.2 specification, and unnamed package should not be used unless the class is explicitly imported.</p>
<p>For example, if myServletClass is in the unnamed package, and you reference it in a &lt;jsp:useServlet&gt; tag, then you must explicitly import myServletClass with the page directive import attribute, as shown in the following example:</p>
<pre> &lt;%@page import=&quot;myServletClass&quot; %&gt;
...
&lt;jsp:useServlet id=&quot;myServlet&quot; class=&quot;myServletClass&quot; scope=&quot;session&quot;/&gt;</pre>
<p>In WebSphere Application Server - Express, the JSP engine creates JSP page implementation classes in the org.apache.jsp package. If a class in the unnamed package is not explicitly imported, then the javac compiler assumes the class is in package org.apache.jsp, and the compilation fails.</p>
<p><strong>Note:</strong> Avoid using the unnamed package altogether because in Java 2 SDK 1.4, the compiler does not accept simple names (or unnamed packages) in the import statements.</p>
</li>
<li>Beginning at WebSphere Application Server - Express Version 5.1.x, the method <tt>java.lang.String getStackTrace()</tt> in <tt>com.ibm.websphere.servlet.error.ServletErrorReport</tt>, has been renamed to <tt>getStackTraceAsString()</tt>. The change was made to accommodate the new method <tt>java.lang.StackTraceElement [] getStackTrace()</tt> found in its parent class, <tt>Throwable</tt>, in JDK 1.4.x. As a result, any application migrated to WebSphere Application Server - Express Version 5.1.x that uses the <tt>getStackTrace()</tt> method in <tt>ServletErrorReporter</tt> needs to be updated to use <tt>getStackTraceAsString()</tt> instead.</li>
</ul>
<p><a name="appissue"></a><strong>Issues concerning the migration of JSPs and Servlets</strong></p>
<p>When you migrate from Version 3.5 to WebSphere Application Server - Express V5.1, servlets and JSPs that are installed in the default Web application (default_app) are not migrated by the WebSphere Application Server migration tools. Options to migrate application components that are installed in the default_app Web application are as follows:</p>
<ol>
<li>Install the servlets and JSPs to a different Web application. The WebSphere Application Server migration tools will then migrate these application components.</li>
<li>Use the WebSphere Application Server migration tools to migrate the resources used by the servlets and JSPs that are installed in the default Web application. The migration tools will migrate resources, such as data sources and virtual hosts. After you have migrated the resources, manually migrate the servlets and JSPs without using the WebSphere Application Server migration tools.</li>
</ol>
<p>If you use the IBM &lt;tsx:dbquery&gt; tag in any of your JSPs, you might need to make additional updates. In Version 5.0, the behavior of the tag's id attribute changed. In previous versions, the id attribute specified the object name of the bean, but now refers to the bean's key name that is stored in the page context. For more information, see <a href="../program/jspqry.htm">&lt;tsx:dbquery&gt;</a> in the <em>Application Development</em> topic.</p>
</body>
</html>