IN JSP <% AND <%!

What is the difference between

<%         %>

and

<%!         %>

Thnak you.
LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?
 
Sathish David Kumar NConnect With a Mentor ArchitectCommented:
<%         %>----------------> 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  .
eg:
<%! 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 ....
0
 
rrzCommented:
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. ?
0
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
rrz@871311,

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.

thx
0
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.

 
rrzCommented:
The solution you at
http://www.experts-exchange.com/Programming/Languages/Java/Q_27651282.html 
will not work for you. Why did you accept it ?
0
 
Sathish David Kumar NArchitectCommented:
check with this solution mike .... it will usefull for you to understand ...
0
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
thanks dravidnsr, t

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

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

      </body>

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
0
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Thank you. I figured out the rest.
0
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.

All Courses

From novice to tech pro — start learning today.