jsp学习之scriptlet的使用方法详解

  

  <%!

  public static final int x=10;

  %>

  <%!

  public int add(int x,int y)

  {

  return x+y;

  }

  %>

  <%!

  class person

  {

  private String name;

  private int age;

  public person(String name,int age)

  {

  this.name=name;

  this.age=age;

  }

  public String toString()

  {

  return "name="+name+",age="+age;

  }

  }

  %>

  <%!

  public int li=20;

  %>

  <%

  person p=new person("test",10);

  out.println(p);

  out.println(li);

  out.println(add(x,20));

  %>

  <%

  int b=10;

  out.println(b);

  %>