Understanding JSP
CASE 1: Try to create method inside <% ,.... %>
We cannot use methods inside <%%>
CASE 2: We can add html code between the JSP scriplets.
Behind the scene :
JSP is converted to a class so this test.jsp is converted to a java class
Java class is basically a servlet
Every jsp is a servlet
When we run it on server (tomcat) , tomcat converts jsp to servlet
Default is get method , Every <%...%> is converted added to doGet method of the servlet class is generated from JSP.
All the HTML code will be put into out.write() by tomcat
Thats why method declared inside <%..%> gives the compilation as we cannot define a method inside a method for that we need : <%!..%>
Last updated
Was this helpful?