This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Expression <%= new Counter() %>  RSS feed

 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I'm new to JSP.

In expression <%= new Counter() %> is "new Counter()" is String or its a object of type Counter.


Even i don't know how to check it programmatically otherwise i would have done.

Ayhow please can anyone explain me.

Thanks in Advance.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jay,

<%= %> is the expression jsp element which is similar to passing the "new Counter " to PrintWriter object and calling toString() to print.

Hence it created new Counter object and calls toString() . (new Counter()).toString() , which returns the object's reference ( mostly memeory address notation )
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a Lot !!! Balu.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are new to JSP, you should start with some good habits right off the bat. The use of Java scriptlet and scriptlet expressions in JSP pages is no longer considered a good practice. Be sure to find yourself a modern tutorial that focuses on use of the JSTL and EL in JSP pages rather than scriptlets.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!