Forums Register Login

Doubt Reagrding inti() method

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
[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.
Your mother was a hamster and your father was a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 595 times.
Similar Threads
Doubt Reagrding inti() method
Calling an EJB from within a Servlet - problem with lookup()
Configuring JSP init parameters
Startup
Clarification in the order in which the DD is read by the container!!
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:10:57.