Home Answers Viewqa JSP-Servlet What is the difference between JSP expression language and scriptlets?

 
 


Ashima
What is the difference between JSP expression language and scriptlets?
1 Answer(s)      4 years and 8 months ago
Posted in : JSP-Servlet

View Answers

September 24, 2008 at 12:37 PM


Hi friend,

Expressions :
The results of evaluating the expression are converted to a string and directly included within the output page.
They are used to display simple values of variables or return values by invoking a bean's getter methods.
They begin within <%= ... %> tags and do not include semicolons:

Scriptlet can contain any number of language statements, variable or method declarations,or expressions that are valid in the page scripting language.
In scriplets declare variables or methods to use later in the file, write expressions valid in the page scripting language,
implicit objects or any object declared.


Scriptlets are used to write the code in any language but that language is mentioned in page language attribute.

ex:<% System.out.println("Hello World "); %>

expession are used to display the simple values and returning values.

ex:

<%! public String getName(){

return "Hello World";

} %>

< %=getName(); %>

For read more information :
http://www.roseindia.net/jsp/

Thanks









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.