All files in opencms are usually stored in the database, which is also known as opencms VFS (Virtual File System ). That is to say, the file structure seen in the opencms workspace does not exist on RFS (real file system, that is, hard disk) (except for static export operations). However, in order for JSP to work properly, all opencms JSP files are mapped to the real file system, that is, they can be found on the hard disk.
To understand this process, let's take a look at how standard JSP files are processed:
- JSP files must be stored in the root directory of the Web application;
- The JSP file must end with "*. jsp" (which can be configured in the web. xml file );
- The servlet container accepts JSP file requests. The requested file is first converted to Java class source code with the extension ". Java ".
- During this process, JSP ctives VES (such as <% @ include file = "..." %>) are also converted to Java source code.
- The generated ". Java" source code is then compiled into a class that implements the servlet interface.
- Finally, the servlet calls the Service () method.
To enable opencms to be unrelated to servlet containers, it uses a simple technique: ing jsp from a Virtual File System to a real file system, as shown below:
- All opencms resource requests are controlled by the opencms servlet, which is usually mapped to/opencms;
- Once opencms receives a request for a jsp resource, it will store the requested JSP file to "/WEB-INF/JSP/" under its own web application root directory;
- Because opencms uses online and offline to distinguish the "release" and "edit" versions of a resource, the online and offline subdirectories are also generated under this directory (/WEB-INF/JSP;
- Under these two directories, the JSP file is stored as a file with the complete VFS path and suffixed with ". jsp;
- For example, the JSP file is "/index. JSP, Which is mapped to "/WEB-INF/JSP/online/index. JSP. JSP, which is called "file name conversion" JSP.
- When opencms stores resources, JSP ctictives (<% @ include file = "... "%> and <% @ page errorpage = "... "%) the JSP files to be mapped are also converted to the real file system;
- Suppose we have a file named "file. jsp" in the Web application directory ";
- Opencms servlet calls requestdispatcher ("{file. jsp}"). Include () and passes control to the standard servlet container. The remaining steps are the same as the standard JSP processing described above.
How to differentiate
Online
And
Offline JSP
Version?In fact, it is very simple: because opencms is stored in two directories for different versions of JSP under online and offline, servlet containers treat them as different files, the modification to the JSP under offline does not affect the JSP under online.
Note:JSP under online and offline have the same web application context. Because of this, they share the following objects under an application. The online and offline JSP pages access the same group of data, using it with caution may cause unexpected side effects. You can strictly control the access to the application context object to avoid these side effects.
In
Opencms
How to use static Export
JSP
?Using opencms static file export can improve the website performance. Opencms also supports static export for JSP file management. Of course, JSP is usually used in dynamic pages. Therefore, the default export attribute of the generated JSP file is false by default. If you want to export JSP files, you must manually set the export attribute of JSP to true.
To support links to static export resources, the <CMS: link> label or cms. Link Method (<CMS: link> usage) is used in opencms ).
In addition, when JSP ctictives contains a file name, do not use a format similar to "<JSP: Directive. include File = "... <% @ include file = "... "%> syntax, because opencms does not support" <JSP: Directive. include File = "... "/>" Syntax Parsing, that is, the JSP file in this syntax cannot be processed, and it cannot be mapped to a real file system. However, other syntaxes that do not contain file names are supported, such as: <JSP: usebean id = "... "/> or <JSP: setproperty name = "... "/>, they can be used normally in the JSP of opencms.
(Thank you for choosing opencms-the first Chinese Resource blog: http://blog.csdn.net/qianxuncms/. we welcome you to communicate directly with the author and make progress together. MSN: qianxuncms@hotmail.com, QQ: 9165456)