• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

JSP declaration

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 67619
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic