CK's BLOG
this site the web

JSP Basic - Lesson 3 - JSP Elements

There are 3 main JSP Elements:

  1. Scripting
  2. Directive
  3. Action
1. Scripting:
There are 3 items in scripting element:
  • Scriptlet: Where you place your java code inside JSP page
Ex: <%
for(int i=0;i<10;i++){
...
}
%>

<jsp:scriptlet>
for(int i=0;i<10;i++){
...
}

</jsp:scriptlet>
These are the same but do try to mix them in single jsp page because its scriptlet has different jspc to compile jsp page to servlet java page => it will confuse the server.

  • Declaration: when you want to declare a variable within class in jsp page but not inside the method in jsp page:
Ex:
<%!
private int i =0;
%>

<jsp:declaration>
private int i =0;
</jsp:declaration>

  • Expression: is used to display from java code inside jsp page to html page.
Ex:
<%=
calculation(10,10)
%>

<jsp:expression>
calculation(10,10)
</jsp:expression>
  1. Directive
There are number of directives and most of them are page directive and most of them are:
  • page import
Ex:
<%@ page import = "java.io" %>
<jsp:directive.page import = "java.io" />

0 comments:

Post a Comment

Thanks for commenting...

 

Just An Information

I will updat useful information as frequent as I could...

Technology

Usage Policies