How to manage JSP in opencms?

Source: Internet
Author: User
Tags website performance

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:

  1. JSP files must be stored in the root directory of the Web application;
  2. The JSP file must end with "*. jsp" (which can be configured in the web. xml file );
  3. The servlet container accepts JSP file requests. The requested file is first converted to Java class source code with the extension ". Java ".
  4. During this process, JSP ctives VES (such as <% @ include file = "..." %>) are also converted to Java source code.
  5. The generated ". Java" source code is then compiled into a class that implements the servlet interface.
  6. 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:
  1. All opencms resource requests are controlled by the opencms servlet, which is usually mapped to/opencms;
  2. 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;
  3. 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;
  4. Under these two directories, the JSP file is stored as a file with the complete VFS path and suffixed with ". jsp;
  5. 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.
  6. 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;
  7. Suppose we have a file named "file. jsp" in the Web application directory ";
  8. 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)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.