The actions applicable to a JSP object are available in each object's context menu (right-click the object to get the context menu). Some of them are:
3. Using the JSP code editorA JSP can be opened in the code editor by double clicking it. The following chapter describes the features available in the code editor.
3.1 Syntax colorizingThe code editor visually distinguishes individual components of a JSP page. A page may consist of three types of elements:
You can control the scripting and content language for each page by the appropriate
properties of each JSP object. Setting the Content Language and Scripting Language
properties affects the coloring of the page in the JSP code editor. Note that setting these
properties does not affect the You can customize the coloring settings for all the elements as follows: Choose Tools | Global Options in the main menu. Expand the Editor Settings node in the Global Options window. Choose JSP Editor, and in the property sheet at the right hand side of the window, customize the Fonts & Colors property.
3.2 AbbreviationsAbbreviations help you in typing some frequently used fragments of code. When you type one of the designated abbreviation and then enter a space, the abbreviation is expanded into a longer string. The following table lists the default abbreviations for the JSP editor.
You can customize the abbreviations as follows: In the main menu, choose Tools | Global Options. Expand the Editor Settings node in the Global Options window. Choose JSP Editor, and in the properties at the right hand side of the window, customize the Abbreviations property.
3.3 Code completionThe code completion feature helps you type JSP code by offering you a list of possible tags, directives, attributes, values, methods, etc. When you press Ctrl+Space while editing JSP code, a code completion window, containing a list of choices, which can be applied at the position of the caret, is displayed. Then you make your choice by moving the highlighted line by "up" and "down" keys. Finally you apply the selected option by presing "Enter" or "Shift+Enter" (the text inserted into code may differ for "Enter" and "Shift+Enter"). Code completion can be used in the following situations:
3.4 Choosing page encoding
You can use the JSP code editor for pages, which are stored on the disk with
a different encoding than the default
Note that this property does not in any way affect the
4. Compiling JSP pages
4.1 The process of JSP compilation
The process of JSP compilation consists of two steps. First, the page is translated
into a Java servlet source by a JSP compiler. Then, the servlet is compiled by
an ordinary Java compiler into a The process of development JSPs when using the IDE is somewhat different than when you use just a text editor and a JSP server. Without the IDE, you edit the JSP file, save it, run the server, and then enter the page URL into your web browser. If your page contains an error, the server will print an exception into its console or into the web browser. This is not very helpful for analyzing the cause of the error. Inside the IDE, the process is much simpler: you edit your page and execute it. This will first save your page and compile it inside the IDE. If your page contained an error, it will be shown in the Output Window. You can then double click the error to go to the line which contains it. Remember that an error can occur in either of the two compilation phases: if the error occurred during the transtation of the JSP to a servlet, the output window will bring you to the JSP source. If the error occurred while compiling the generated servlet, the servlet source will appear after double-clicking the error. After compiling the page, the Execute action starts a web server and displays the page in a web browser.
4.2 Viewing the servlet, building and cleaningWhen a JSP has been successfully compiled, you can see the generated servlet by choosing View Servlet in the page object's popup menu. This can help you better analyze what the page is doing. You may notice that when you compile the same page several times, the name of the generated servlet changes: every compilation cycle increases the number appended to the end of the name. The reason for that is that this way the server can reload a new version of a JSP, just by loading a new class file. So the server does not need to be restarted to load a new version of the page. This means that during the process of JSP development, multiple generated servlets will exist on the disk. You can delete all the versions of the page by running the Clean action (in the Build submenu of the main menu). You can use the Build action (in the same menu) to first clean the page and then compile it.
4.3 Dependencies among the compiled files
Every JSP page may have relationships to other files, Java classes and other JSP pages.
For example, a page may include other files by the The above relationships play a significant role in the JSP compilation process.
When you compile a JSP, all beans used by this page will be automcatically compiled as well.
You may also choose to automatically compile all pages referenced by a JSP by the
Similarly, to enable or disable the compilation of a JSP's error page when compiling the primary JSP, set the Also Compile Error Page property to the desired value.
4.4 Setting the Java compiler
As was already mentioned above, the JSP compiler first translates the JSP into a servlet, and then compiles
the servlet into a You can set a servlet compiler for individual JSPs by the Servlet Compiler property in the JSP object's property sheet (Execution tab). You can also set a default compiler, which will be used for pages for which no specific Java compiler has been set. This can be done by selecting Tools | Global Options in the main menu, and then setting the Default JSP Servlet Compiler property in the JSP node. If you do not set this property, the compiler set in Project | Settings | Java Sources | Default Compiler will be used.
5. Executing JSP pagesThe JSP execution feature allows you to test your pages by running them in the Tomcat 3.2 server and displaying them in your favorite web browser.
5.1 Execute and Execute (restart server) actionsYou can use the Execute and Execute (restart server) actions from a JSP object's context menu to test run this JSP in a web server. These actions do roughly the following:
The URL of the page in the web browser is largely determined by the location of the page. You can define the query string appended at the end of the URL by setting the Request Parameters property of the JSP page. By default, if you run a JSP, the Tomcat web server is started, and subsequent executions of this or other pages use this instance of the server. If you have modified the page between executions, the new version of the page is always reloaded into the server, which eleminates the need to restart the server each time you modify a page. In some cases, however, you may want to explicitly tell the IDE to restart the server. An example of such a situation is when you have modified a JavaBean used by the page. As beans can not be reloaded, the server needs to be restarted. You can force server restart by using the Execute (restart server) action. Alternatively, you can use the Terminate Process action on the server process node in the Execution window (Running workspace). The IDE may restart the server in some cases also when you use the Execute action. The cases when the server is restarted include the situation when the executed JSP resides on a different filesystem than the originally executed page, or when you have used the Build or Clean actions on any page.
5.2 Setting executor propertiesFor every page, you can set an Executor in the page object's property sheet, in the Execution tab. This property determines which execution service will be used for executing this JSP. You can set up several JSP execution services, and each page may use a different executor. JSP executors can be set up in the Project | Settings menu. Under Execution Types, you will find JSP Execution. Follows the meaning of some of the JSP Execution properties:
These properties affect the server configuration file generated by the execute action. The configuration file is also affected by other ways. Notably, the document base of the server is set to the root of the filesystem, which contains the executed JSP.
5.3 Setting the web browserBy default, your pages will be displayed in the IDE built-in web browser (ICEBrowser 4.0). However, you can set any browser of your choice in the JSP options: choose Tools | Global Options in the main menu. In the Global Options window, select the JSP node. Then customize the Web Browser property.
The selected browser will be used to display executed JSP pages.
|
j2eeNetBeans.org |