Jxp (Java scripted page) is a script-processor that process JSP-like files. It contains a parser to parse the script file into an abstract syntax tree and a tree processor (JxpProcessor) that will process the syntax tree to execute the code using reflection API to produce output. The main uses of Jxp are:
This is normal text
This is text with variable <%=var1%>
This is another text with variable `var1`
This is yet another text with expression `var1.toString()`
<!-- jsp style import -->
<%@ page import="java.util.*"%>
<%! String text = "text"; %>
<jsp:declaration>
String anotherText = "text";
</jsp:declaration>
This is output jsp expression output <%=text%>
This is EL output ${text}
<%
//scriptlet
import java.util.*;
//print
println("This text is printed by jxp");
//populate the list with 1 to 10
var i = 0;
List l = new ArrayList();
for (int i = 0; i<10; i++)
{
l.add(new Integer(i));
}
//include another script
include("config.jxp");
//try and catch
try
{
File f = new File("data.txt");
} catch (Exception e)
{
//do nothing
}
//function definition and function call
function void f1(String arg){
//do somethod
}
f1("test"); //call it here
//synchronize
Object o = new Object();
synchronized (o)
{
//do something
}
%>