JavaServer Pages troubleshooting tips

Use this tips to troubleshoot problems with JavaServer Pages.

JavaServer Pages source code shown by the web server

If you share the document root of the WebSphere® Application Server with the web server document root, a security exposure can result as the web server might display the JavaServer Pages (JSP) source file as plain text.

Problem
You can use the WebSphere Web server plug-in set of rules to determine whether a given request will be handled by the WebSphere Application Server. When an incoming request fails to match those rules, the web server plug-in returns control to the web server so that the web server can fulfill the request. In this case, the unknown host header causes the web server plug-in to return control to the web server because the rules do not indicate that the WebSphere Application Server should handle it. Therefore, the web server looks for the request in the web server document root. Since the JSP source file is stored in the document root of the web server, the web server finds the file and displays it as plain text.
Suggested solution
Move the WebSphere Application Server JSP source file outside of the web server document root. Then, when this request comes in with the unknown host header, the plug-in returns control to the web server and the JSP source file is not found in the document root. Therefore, the web server returns a 404 File Not Found error rather than the JSP source file.

Problems displaying double-byte character set (DBCS) characters when using the @include directive

JavaServer Pages files that use the @include directive might experience problems when displaying double-byte character set (DBCS) characters. Some applications that are migrated to WebSphere Application Server Version 6.0 and later might need to be modified to comply with the JSP 2.0 specification as a result of backwards compatibility issues. The JSP 2.0 specification requires that each statically included resource must set a page encoding or content type because the character encoding for each file is determined separately, even if one file includes another using the include directive.

Problems using the JavaServer Pages (JSP) engine

If you are having difficulty using the JavaServer Pages (JSP) engine, try these steps:
  1. Determine whether other resources such as .html files or servlets are being requested and displayed correctly. If they are not, the problem probably lies at a deeper level, such as with the HTTP server.
  2. If other resources are being displayed correctly, determine whether the JSP processor has started normally:
    • [AIX Solaris HP-UX Linux Windows][IBM i]Browse the JVM logs of the server hosting the JSP files you are trying to access. The following messages indicate that the JSP processor has started normally:
      Extension Processor [class com.ibm.ws.jsp.webcontainerext.JSPExtensionProcessor] 
      was initialized successfully. 
      Extension Processor [class com.ibm.ws.jsp.webcontainerext.JSPExtensionProcessor] 
      has been associated with patterns [*.jsp *.jspx *.jsw *.jsv ].
      If the JSP processor fails to load, you will see a message such as
      No Extension Processor found for handling JSPs.
      JSP Processor not defined. Skipping : jspfilename.
      in the root_dir/logs/server_name/SystemOut.log file
    • [z/OS]Browse the logs of the server hosting the JSP files you are trying to access. The following messages indicate that the JSP processor has started normally:
      Extension Processor [class com.ibm.ws.jsp.webcontainerext.JSPExtensionProcessor] 
      was initialized successfully. 
      Extension Processor [class com.ibm.ws.jsp.webcontainerext.JSPExtensionProcessor] 
      has been associated with patterns [*.jsp *.jspx *.jsw *.jsv ].
      If the JSP processor fails to load, you will see a message such as
      No Extension Processor found for handling JSPs.
      JSP Processor not defined. Skipping : jspfilename.
      in the server log files.
  3. If the JSP engine has started normally, the problem may be with the JSP file itself.
    • [AIX Solaris HP-UX Linux Windows][IBM i]The JSP may have invalid JSP syntax and could not be processed by the JSP Processor. Examine the root_dir/logs/server_name/SystemOut.log file of the target application for invalid JSP directive syntax messages. Errors similar to the following in a browser indicate this kind of problem:
      Message: /filename.jsp(2,1)JSPG0076E: Missing required attribute page for jsp 
                   element jsp:include 
      This example indicates that line 2, column 1 of the named JavaServer Pages file is missing a mandatory attribute for the jsp:include action. Similar messages are displayed for other syntax errors.
    • [z/OS]The JSP may have invalid JSP syntax and could not be processed by the JSP Processor. Examine the server log files of the target application for invalid JSP directive syntax messages. Errors similar to the following in a browser indicate this kind of problem:
      Message: /filename.jsp(2,1)JSPG0076E: Missing required attribute page for jsp 
                  element jsp:include 
      This example indicates that line 2, column 1 of the named JavaServer Pages file is missing a mandatory attribute for the jsp:include action. Similar messages are displayed for other syntax errors.
    • Examine the target application server's SystemErr.log files for problems with invalid Java™ syntax. Errors similar to Message: Unable to compile class for JSP in a browser indicate this kind of problem.
      The error message output from the Javac compiler will be found in the SystemErr.log file. It might look like:
      JSPG0091E: An error occurred at line: 2 in the file: /myJsp.jsp 
      JSPG0093E: Generated servlet error: c:\WASROOT\temp\ ... 
      test.war\_myJsp.java:16: myInt is already defined in com.ibm.ws.jsp20._myJsp 
      int myInt = 122; String myString = "number is 122"; static int myStaticInt=22; 
      int myInt=121;                    
               ^  1 error

      Correct the error in the JSP file and retry the file.

    • Examine the log files for the target application for problems with invalid Java syntax. Errors similar to Message: Unable to compile class for JSP in a browser indicate this kind of problem.
      [AIX Solaris HP-UX Linux Windows][IBM i]The error message output from the Javac compiler will be found in the SystemErr.log. It might look like:
      JSPG0091E: An error occurred at line: 2 in the file: /myJsp.jsp 
      JSPG0093E: Generated servlet error: c:\WASROOT\temp\ ... 
      test.war\_myJsp.java:16: myInt is already defined in com.ibm.ws.jsp20._myJsp 
      int myInt = 122; String myString = "number is 122"; static int myStaticInt=22; 
      int myInt=121;                    
               ^  1 error
      [z/OS]The error message output from the Javac compiler will be found in the server log files. It might look like:
      JSPG0091E: An error occurred at line: 2 in the file: /myJsp.jsp 
      JSPG0093E: Generated servlet error: c:\WASROOT\temp\ ... 
      test.war\_myJsp.java:16: myInt is already defined in com.ibm.ws.jsp20._myJsp 
      int myInt = 122; String myString = "number is 122"; static int myStaticInt=22; 
      int myInt=121;                    
               ^  1 error

      Correct the error in the JSP file and retry the file.

Note: 這個主題參照一或多個應用程式伺服器日誌檔。 此外,在分散式和 IBM® i 系統上,另外也建議您可以配置伺服器來使用「高效能可延伸記載 (HPEL)」日誌和追蹤基礎架構,而不使用 SystemOut.logSystemErr.log, trace.logactivity.log 檔案。HPEL 與原生 z/OS® 記載機能也可以一起使用。如果您使用 HPEL,則可以從伺服器設定檔 bin 目錄,利用 LogViewer 指令行工具來存取您所有的日誌和追蹤資訊。請參閱有關利用 HPEL 疑難排解應用程式的資訊,以取得更多使用 HPEL 的相關資訊。

JavaServer Pages fail to compile when using precompile

Symptom Problem Suggested solution
JavaServer Pages fail to compile during deployment through the administrative console when precompile is selected.
SystemErr R com.ibm.websphere
 .management.exception
 .AdminException: 
ADMA0021E: Error in compiling jsps -
 xyz.war (rc=1)
JavaServer Pages fail to compile during deployment through the administrative console when precompile is selected when there is a dependency on another Java archive (JAR) file that is not available on any class path. You may use wsadmin scripting to precompile JSP files during enterprise application deployment. However if you want to use the administrative console, then compile all JSP files before packaging the application.
  1. Add the dependent JAR to the deployment manager in a cell environment.
    1. Click System Administration > Deployment manager > Java and Process Management > Process Definition > Java Virtual Machine in the console navigation.
    2. Add fully qualified dependent JAR in class path field.
    3. Click OK.
    4. Restart deployment manager.

JSPG0089E: Mismatch found between page directive encoding Shift_JIS and xml prolog encoding UTF-8

Symptom Problem Suggested solution
The following error appears:
JSP Processing Error

HTTP Error Code: 500

Error Message: /test.jsp(2,1) 
	/test.jsp(2,1) JSPG0089E: 
	Mismatch found between page 
	directive encoding Shift_JIS 
	and xml prolog encoding UTF-8
The pageEncoding attribute in the jsp:directive.page element is not UTF-8. JavaServer Pages must specify a prolog that matches the encoding specified in the page directive. For example,
<?xml version="1.0" encoding="Shift_JIS"?>
<jsp:root xmlns:jsp="http://java.sun.com/
 JSP/Page" version="2.0">
<jsp:directive.page language="java" 
 contentType="text/html";
	charset=Shift_JIS pageEncoding=
	 "Shift_JIS"/>
<jsp:text>XXXXXjsp:text>XXXXX>
</jsp:root>

For additional information, see section JSP.4.1, Page Character Encoding, in the JavaServer Pages specification and section 4.3.3 and appendix F.1 of the Extensible Markup Language (XML) specification

If none of these steps solves the problem, check to see if the problem is identified and documented using the links in the topic, Diagnosing and fixing problems: Resources for learning. If you do not see a problem that resembles yours, or if the information provided does not solve your problem, contact IBM support for further assistance.

For current information available from IBM Support on known problems and their resolution, see the IBM Support page. The IBM Support page contains documents that can save you time gathering information needed to resolve this problem.


指出主題類型的圖示 參照主題



時間戳記圖示 前次更新: July 9, 2016 11:13
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rtrb_jspcomp
檔名:rtrb_jspcomp.html