0

I am fairly new to JSP but I am pretty good at Java.

In some tutorials on the internet you use

<%

and other times you use

<%!

What is the difference between these two exactly?

OmniOwl
  • 5,477
  • 17
  • 67
  • 116
  • possible duplicate of [What is the difference between <% ... %> and <%! ... %> in jsp](http://stackoverflow.com/questions/3333138/what-is-the-difference-between-and-in-jsp) – BalusC Jun 27 '13 at 11:05
  • Related: [How to avoid Java code in JSP files?](http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files/) The style which you're showing there is discouraged since a decade. Perhaps you were reading heavily outdated tutorials? – BalusC Jun 27 '13 at 11:06
  • I need to press a button on a website. When I press it, I will fetch some data from a database and make an Excel spreadsheet accordingly. I just didn't want to ask that kind of question. – OmniOwl Jun 27 '13 at 11:11

2 Answers2

1

The <%! is used for class content declarations and <% is used for request method body instructions.

Take a look at an example of JSP Tutorial - Declarations

Michal Borek
  • 4,584
  • 2
  • 30
  • 40
0

<% is for normal jsp scriplets and <%! is for static methods and variables.

Smern
  • 18,746
  • 21
  • 72
  • 90
Don Srinath
  • 1,565
  • 1
  • 21
  • 32