1. Switch to the "offline" Project
In opencms, JSP files can be created and edited only in the "offline" project State. Therefore, you must switch from the "online" project state to the "offline" project state before creating a JSP file.
2. Start "new"
Under the "offlinne" project, go to the folder where you want to create the JSP file, and click the "new" button:
3. Select "jsp" Type
In the displayed "Resource Type dialog box", select the "jsp" type:
Note: not all options are available to all users. "jsp" and "XML" template resources are only valid for users in the "Administrators" group, users in this group cannot create or edit these two types of resources. This is also purposeful. The design of JSP programs should be limited to developers. Developers usually need the permissions of the administrato, at least in the development process.
4. End the creation wizard
In the next step, enter the name of the JSP file to be created and related attributes of the file.
Name: suffix,. cgi,. asp,. php, and so on. opencms does not automatically add an extension.
In the next step, enter other attributes of the newly created JSP file.
Title(Optional)
Enter the "title" attribute of the JSP file. The "title" attribute is displayed in the view of the opencms workspace. In future documents, you will use the <title> tag of JSP, this attribute is not mandatory, but it is a good habit to input attributes for each resource in opencms.
Cache(Optional)
In opencms, you can set cache for JSP files. If you do not enter any content here, this JSP file will not be cached. In this example, NO content is entered for the moment.
Content-Encoding(Optional)
JSP content-encoding, unless you need a different setting, you should set it here as "UTF-8 ", so do not fill in ).
Export(Optional)
The export attribute determines the behavior of JSP files during static export operations. Because most JSP files contain dynamic content, you should set the export attribute to "false ".
Click "end". The JSP file creation process ends.
5. Open the JSP file in the editor.
Now you can see the newly created JSP file in the browser view. It should beBlueTo edit the file, click the red JSP icon and a menu will pop up, edit "Edit source code" to open the JSP file in the editor.
6. Edit JSP files
In the editor, you can edit the content of the JSP file you want. This source code editor is easy to use and is not described in detail. Now you can start to write your JSP code. As an example, let's create a "Hello, world" Example:
<% ...
StringHello= "Hello, world";
%>
< H1 > <% = Hello %> From opencms </ H1 >
The time is <% = New Java. util. Date () %>
Save and exit the editor. In the opencms browser view, click the edited JSP file. The displayed page should be as follows:
Note: This JSP file has not yet been released. When you switch to the "online" project, you will not see the newly created JSP file in the list. As we have said before, in opencms, the same JSP is distinguished by online and offline versions, and other content is also distinguished.
7. Release JSP files
The last step is to release the newly created or edited JSP file, switch to the "offline" project, and click "publish project" to release the JSP file, for example:
Because the JSP file lock has not been unlocked, you will be prompted whether to unlock the file lock in all projects. After confirmation, opencms will release all the modified resources, A dialog box for the release process is displayed. After the release is complete, click "OK" to return to the browsing view. The JPs file is now released. It is no longer blue, but black, identify that the resource has been released and has not been modified in the offline project. Now you can switch to the "online" project. Then you will see the released JSP file.
Now, you have created a "standard" JSP file in opencms.