OpenCMS how to manage JSP files

xiaoxiao2021-04-02  215

Usually OpenCMS files are stored in the database, that is, the so-called

Virtual File System (VFS). This means that there is no explorer view of the OpenCMS Workplace in the local file system. However, in order to make the JSP file work normally, all JSP files in OpenCMS "mirror icon" to the local file system.

Let's take a look at how a "standard" JSP file is processed:

The JSP file must exist in the directory of the web application. The suffix of the file must be .jsp (you can modify this by configuring web.xml). When the Servlet container receives a request for a JSP file for a web application, the requested JSP file first is converted to a Java source file, ie .java file. During the conversion process, the JSP tag (such as <% @ include file = "..."%>) is parsed and converted into Java code. The conversion Java file implements the servlet interface and compiled into a Class file. Finally, call the service service () method. In order to make OpenCMS independently of the servlet container, it uses a small trick-to mirror the JSP file from the VFS to the local file system, the method is as follows:

The request for all resources of OpenCMS is processed by the OpenCMS servlet, which is generally mapped to / OpenCMS / OpenCMS. When OpenCMS receives a request to the JSP resource, it imports the contents of the request JSP file into a subdirectory / Web-INF / JSP of the root of the OpenCMS web app. Because OpenCMS resources are divided into online and offline, / web-inf / jsp exists in subdirectory online and offline and this correspondence. In this directory, the exported JSP file has a complete VFS path structure and .jsp suffix. For example, your file is "/index.jsp" in VFS, it will be a web-inf / jsp / online / index.jsp.jsp file (Translator Note: Current OpenCMS6.2.1 can judge the exported file) Whether there is a JSP suffix, not a silly direct addition). We can put this "conversion file name" of this JSP. When OpenCMS exports resources, a simple parser will be used to preprocess the content of JSP files to find out the expression of other JSP files. The most obvious is <% @ include file = "..."%> and <% @ Page ErrorPage = "..."%> If this label is found, the target file name will be replaced by this resource in the true file system. Now we already have a JSP file in the directory of the web application, we call him "{file.jsp}" OpenCMS servlet (it is still the controller) now calls RequestDispatcher ("{file.jsp}"). Include () , Then turn the control to the standard servlet container. Then proceed according to the standard JSP processing steps described above. It should be noted that in this process, OpenCMS still uses the Request and Response wrappers to generate a FlexCache entry.

转载请注明原文地址:https://www.9cbs.com/read-131389.html

New Post(0)