<%-- Directive controlling overall page: --%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %> JSP structure - XML syntax <%-- Declaration of class, field and method: --%> public class X { private String s; public X(String s) { this.s = s; } public String getS() { return s; } } private X[] x = new X[2]; private void setTwo(String s1, String s2) { x[0] = new X(s1); x[1] = new X(s2); }

JSP structure - XML syntax

Demo:

<%-- Scriptlet calling method: --%> setTwo("ABC", "DEF"); <%-- Expressions outputting: --%> x[0].getS()
x[1].getS()