Reputation: 8943
Although I know JSP (basic understanding), I have some doubts on the JSP technology.
<html>
<head>
<title> This is demo</title>
</head>
<body>
<h1> The current time is <%=new java.util.Date()%> </h1>
</body>
</html>
With respect to this, I have some doubts (which I have been keeping at the back of my mind):
1) The basic text of this jsp is same, is it dynamic page because it has JAVA code in it?
2) When a user accesses this jsp page, does the container first execute the java code and replaces the output of java code inside the page?
3) What makes this a jsp page? Do mixing of html and java code make it a jsp?
4) Can the java code (within <% %> ) live independent of html? or they are coupled (the java code has to be present in html page).
They might be basic questions, can anyone help me in understanding them?
Upvotes: -3
Views: 653
Reputation: 149145
HttpServlet
interface can be directly map to an URL by the servlet container. And Java code can lie in a scriptlet in a JSPBut as you were said in comment, you really should read documentation on that before asking questions here.
Upvotes: 1
Reputation: 676
1) it's dynamic if it contains any JSP elements, like code snippets, JSP tags etc. If it contains only HTML, then it's pretty static, although if it is processed as a JSP, then the constant response is computed dynamically on each call (safe Caching).
2) yeah much like that. Actually the static text of the JSP goes into out.write() Statements in a Java class; the whole JSP is transpiled to a Java class.
3) funny question. It's all a question of Interpretation. If you name it .jsp or have your web container process it as JSP in some other ways (depends), then you may call it a JSP.
4) this question is not quite clear. The snippets are executed after the static text has been output up to this point.
Upvotes: 1