Subscribe to Java/SCJP        RSS Feed
-----

The HTML you thought to be present in your JSP

Icon Leave Comment
Consider the code below:

<html>
<title>result</title>
<body>
<%= new java.util.Date()%>
<% String str = (String)session.getAttribute("name");
   if(str == null) {
	   session.setAttribute("name","only hello");
%>
	   this is good hello
<%  }
   else {
	   out.println( str);
   }
%>
</body>




Do the html tags go as it is to the browser?
No, they are converted to out.println statements when the servlet for JSP is created and then sent to browser, when a request comes from browser.
This also means that in the above example, "this is good hello" text is skipped if str!=null.
In fact, all the code in scriptlets is inserted into _jspService method.

0 Comments On This Entry

 

January 2022

S M T W T F S
      1
2345678
9101112131415
161718192021 22
23242526272829
3031     

Recent Entries

Recent Comments

Search My Blog

12 user(s) viewing

12 Guests
0 member(s)
0 anonymous member(s)