Advanced Java Programming - Old Questions

10. What is JSP? Discuss with suitable example.

5 marks | Asked in 2073

Java Server Pages (JSP) is server side technology to create dynamic java web application. It allows java programming code to be embedded in the HTML pages.

  • Scripting elements are used to provide dynamic pages.
  • JSP simply puts Java inside HTML pages.

JSP provides the following scripting elements:

1. JSP Comments:

Syntax:

      <%-- comments --%>

2. JSP Scriplet: A scriptlet tag is used to execute java source code in JSP.

Syntax:

      <% java source code; %> 

3. JSP Expression:

JSP expression can be used to insert a single java expression directly into the response message. This expression will be place inside a out.print() method.

Syntax:

      <%= Java Expression %>

4. JSP Declaration: JSP declaration tag is used to declare variables and methods.

Syntax:

      <%! Variable or method declaration %>

Example