This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP declaration" Watch "JSP declaration" New topic
Author

JSP declaration

Bala MuraliKrishna
Greenhorn

Joined: Mar 31, 2005
Posts: 2
The following question is there in one of the mock exam in jdiscuss. I have verified the output and the output is aaabbb.

<html>
<body>
<% String a = "aaa"; %>
<%! String a = "AAA"; %>
<%! String b = "BBB"; %>
<% String b = "bbb"; %>
<% out.println(a+b); %>
</body>
</html>

some one please explain me the logic behind this scenario.

Bala
SCJP
Dream Java!
Bala MuraliKrishna
Greenhorn

Joined: Mar 31, 2005
Posts: 2
Sorry for the above code which was modified by me while evaluating the output. Please refer below given code. Sorry for the inconvenience caused.

<html>
<body>
<% String a = "aaa"; %>
<%! String a = "AAA"; %>
<% String b = "bbb"; %>
<%! String b = "BBB"; %>
<% out.println(a+b); %>
</body>
</html>

Thanks
Bala
SCJP
Dream Java!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

The best way to figure out what is going on is to have a look at the Java servlet that the container will create on behalf of your JSP page. This is perhaps the most instructive thing you can do to find out why JSPs behave the way that they do.

For Tomcat, the Java files are written to the folder hierarchy at $CATALINA_HOME/work.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP declaration
 
Similar Threads
JSTL c:if tag is not working in JSF page
Doubt on an Jsp file
Any body can help ? Thank you
Question ID :1000043338670
General concept