You can writer java code in JAVA statement.JAVA statement begin with <% and end with %> .
You can't define a class or an interface or a function in JAVA statement.
Import statement and package statement are not supported too.
Template tags such as article tags and global tags can be used in java code and none statement can be nested in JAVA statement directly.
<%
--input java code here
%>
All variables and methods defined by nps.compiler.ArticleClassBase can be used in article template.
All variables and methods defined by nps.compiler.PageClassBase can be used in page template.
| variable | type | meaning |
|---|---|---|
| ctxt | NpsContext | current context object.All objects can get such as database connection,current user and site etc. |
| site | Site | current site object |
| top | Topic | current topic object |
| art | Article | current article object.Only valid in article template. self-defined datasource objects are derived from CustomArticle,and others derived from NormalArticle |
| out | JavaWriter | Writer for html data. out.print(Object) means to print the string. out.printil(Object) means to print the current indention, and then the string, and a '\n'. out.println(Object) means to print the given string followed by '\n' |
| print() | Function | Since V1.5. Please use these methods instead of out.print() to output html data. print(Object) means to print the object, which could be an Integer, String or Clob printil(Object) means to print the current indention, and then the String and a '\n' println(Object) means to print the given string followed by '\n' |
Codes for only output even line.
<rs id="rs1" sql="select name,price from product">
<%
if((Integer)<$rs1.rowno$>%2==0)
{
%>
<$rs1.name$>:<$rs1.price$>
<%
}
%>
</rs>