• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

IN JSP <% AND <%!

What is the difference between

<%         %>


<%!         %>

Thnak you.
Mike Eghtebas
Mike Eghtebas
  • 3
  • 2
  • 2
1 Solution
I would like to help you but I don't think you have been honest with me in your last two questions.
Did you even try my suggestions. ?
Mike EghtebasDatabase and Application DeveloperAuthor Commented:

My apology for that. After work when I am home I would respond.

I was under gun and have to shift my focus elsewhere, Also, there was server setup which was adjusted and the attending to the question was not priority.

I will get back to you.

Also I thing <!-- to do with sort of public deceleration or just deceleration.

I am new and confused right now.

The solution you at
will not work for you. Why did you accept it ?
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Sathish David Kumar NArchitectCommented:
<%         %>----------------> this is scriptlet

<%!    %> ------------> this declerative  

both are usefull to right java code but the main diffrences is if you want to use any filed or method any where in jsp then you can go with declerative  .
<%! String s="Sathish" %>
<% String  s1="David" %>

here you can use s in any where in your jsp but s1 will accessable inside the scriplet only ....
Sathish David Kumar NArchitectCommented:
check with this solution mike .... it will usefull for you to understand ...
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
thanks dravidnsr, t

o post No instead of null, I am using the following code:

             <%! String str = "No" %>   <-- is this correct?
            str = ((request.getParameter("margherita") != null)? "Yes":"No");
            <% out.println(request.getParameter("hawaiian")); %>
            <% out.println(request.getParameter("pepperoni")); %>


I want to declare str once such that its scope will hande all three items. After the first one works, I wiil change the remainig two.

Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Thank you. I figured out the rest.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now