Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

tags questions

Posted on 2003-11-06
6
Medium Priority
?
270 Views
Last Modified: 2010-04-01
1.What is the difference beween thes two and what differing effect will they have on the page an system
2.in what situation would you use one or the other

<%!
int a = 0
%>

and

<%
int a = 0
%>


0
Comment
Question by:danBosh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 9694837
1. this is homework
2. read your book
3. <%! is for method/class declaration
4. <% this stuff goes into doGet()/doPost() when converted to servlet (which all jsps are)
0
 

Author Comment

by:danBosh
ID: 9694873
its not home work, im 22 and a IT consultant
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 80 total points
ID: 9695067
ok, well then 3 and 4 answer your question anyway.

ie:

<%!
   private String saySomething(String s) {
      return s;
   }
%>

try and do the above w/o the !

<%
   out.println(saySomething("Hello World")); // this gets executed automatically on page load
%>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 28

Expert Comment

by:rrz
ID: 9696482
I agree with everything that bobbit31 posted.
Also,
the scriptlet is thread safe, but the declaration is not safe because it is inserted into the main body of the servlet class.  
The declaration is a place to store data that is persistent between requests.
You can put a inner class in a declaration.
0
 
LVL 28

Expert Comment

by:rrz
ID: 9696533
One more thing.
You could use a declaration to override the jspInit and jspDestroy methods of your JSP.
0
 
LVL 3

Expert Comment

by:applekanna
ID: 9698715
Just a note ... though not any different from the other posts...

<%!
int a = 0
%>

when the JSP is converted to servelt code by the engine it put this seperately like a method in your program that can be accesed from anywhere.

<%
int a = 0
%>     is duplicated in the servcice() method of the servelt as is where is

Hope this helps
Cheers!

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working from home is a dream for many people who aren’t happy about getting up early, going to the office, and spending long hours at work. There are lots of benefits of remote work for employees.
Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question