aspose file tools*
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 Java 8 in Action this week in the Java 8 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: 60077
    
  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]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JSP declaration
 
Similar Threads
General concept
Any body can help ? Thank you
Doubt on an Jsp file
Question ID :1000043338670
JSTL c:if tag is not working in JSF page