Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

error in jsp

i am stuck in this problem for 2 days. please help.

i am writing a method inside my jsp but it is giving me error

<%
   public void callMe() {
        ........
   }
 %>

Isn't it legal to write methods inside Jsp.?

0
niti20
Asked:
niti20
1 Solution
 
thomas908Commented:
You can't write a method inside a scriptlet. Whatever you write in a scriptelt goes inside the service method when the JSP code is translated to a servlet. So a method inside a scriptlet would mean a method inside the service method and that would be totally wrong as there is no concept of inner methods in Java.

if u want to write method inside a JSP, it must be in a declaration and not a scriptlet

<%!  
   //      method goes here
%>
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now