Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt Reagrding inti() method  RSS feed

 
Akhilesh Yadav
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As we all know every jsp is converted in to servlet

when in write jsp declration tag <%! public void a(){} %>
this will go into init() method of servlet

but when i write Expression <% public void a(){} %>
this will go into service() method of servlet

in expression tag it ie.service() shows error illegal start of expression .....

why it doesnt show in init() method the same error because even init() is a method.
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Akhilesh Yadav]when in write jsp declration tag <%! public void a(){} %>
this will go into init() method of servlet


This would not go into the init() method. This would declare a new method in the servlet.

As method can not contain any other method directly, declaring a method in a <% %> would lead to an error as all the code would be put in the service() method.
 
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!