This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
    Bookmark Topic Watch Topic
  • New Topic

Doubt Reagrding inti() method  RSS feed

 
Akhilesh Yadav
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • 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.
 
Karthick Sundaram
Greenhorn
Posts: 15
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
>> "when in write jsp declration tag <%! public void a(){} %>
this will go into init() method of servlet"


<%! somevalidjavadeclaration %>
No It goes outside the init() method..
1.as another method if it is a method declared..
2.or as an instance variable if some variable was declared

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

<% SomeValidJavaVariableDeclaration %>
It goes inside the service() method.

You can only have a variable declared or defined. but not a method.(How can a method go into another method?)
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!