File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP declaration

 
Bala MuraliKrishna
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic