InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.2: Developing JSP files >
4.2.2.3: Overview of JSP file content >
4.2.2.3.2: JSP syntax: Class-wide variables and methods

4.2.2.3.2: JSP syntax: Class-wide variables and methods

Use the <SCRIPT> and </SCRIPT> tags to declare class-wide variables and class-wide methods for the servlet class. The general syntax is:

<script runat=server>

// code for class-wide variables and methods

</script>

The attribute runat=server is required and indicates that the tag is for server-side processing. An example of specifying class-wide variables and methods:

<script runat=server>

// class-wide variables
init i = 0;
String foo = "Hello";

// class-wide methods
private void foo() {// code for the method}  </script>
Go to previous article: JSP  syntax: JSP directives Go to next article: JSP syntax: Inline Java code (scriptlets)

 

 
Go to previous article: JSP  syntax: JSP directives Go to next article: JSP syntax: Inline Java code (scriptlets)