defn:
Includes a page at the given location in the main page.
Syntax:
<jsp:include page="{PAGE_TO_INCLUDE}" flush="true"/>
It is as simple as name suggests, simple include a give jsp or html page in your main jsp page at the given location in the main page.
For example, I have my main jsp page:
i have a code in my jsp page like below:
{
--//code-
---
//here im including another jsp page for my jsp page
<jsp:include page="{PAGE_TO_INCLUDE}" flush="true"/>
----
//code
....
}
Here i have a code, in between code in my main jsp page, Im including jsp code(another jsp page) using the jsp include action
So here what Im simply doing is , here im including the content of another jsp page in my main jsp page at the given location
So you would have heard of similar concept earlier in this class, it is during "jsp directive", i explained in "jsp directive" that we could include a page in my main page and where you would usually use this probably you can say you can have certain common features in every jsp page like a header or footer you can use those kind of things to include in your main jsp page. So every page a will have a same header or footer.
Difference between include directive and include action
----------------------------------------------------------------------------------------------------------
include directive include action
------------------------------------------------------------------------------------------------------------
1. Translation Time Run time
2. Copies the included file References to the included file
3. For static content For dynamic content
4. can not pass parameters can pass parameters
--------------------------------------------------------------------------------------------------------
1. Translation Time:
Basically the page included means included your main jsp page at translation time, that means whenever your jsp translated to a servlet at that point of time even the included jsp pages content is got into the main jsp page and then it is tanslated to a servlet.
1. Run time:
It is not done at translation time so even though your servlet, eventhough your jsp translates into servlet it does not really content the included jsp content in the main page but it gets the content at run time when you execute that page
2. copies the included file:
Because it done at translation time it is simply copies all the content from your included page to main page
2. References to the included file:
Since we did not do at translation time simply keeps the included page at its own path and it has some kind of link or reference in the main page where it points to this included page and it craps this content of the included page at that run time and then populates.
3. static content:
including the translation time itself, this is more likely to use for static content, because like for example that your sub page has changed but your main has not changed and if you go and try to give this page again you wont see the latest change made in your sub page because the static content included page content was included in your main page at translation time and translation happens only once and it happens at first time and it happens whenever you changes your main page. Since you didnt make any chages in your main page, no translations happens again that means same static content present in your main page.
3. For dynamic content:
Includes a page at the given location in the main page.
Syntax:
<jsp:include page="{PAGE_TO_INCLUDE}" flush="true"/>
It is as simple as name suggests, simple include a give jsp or html page in your main jsp page at the given location in the main page.
For example, I have my main jsp page:
i have a code in my jsp page like below:
{
--//code-
---
//here im including another jsp page for my jsp page
<jsp:include page="{PAGE_TO_INCLUDE}" flush="true"/>
----
//code
....
}
Here i have a code, in between code in my main jsp page, Im including jsp code(another jsp page) using the jsp include action
So here what Im simply doing is , here im including the content of another jsp page in my main jsp page at the given location
So you would have heard of similar concept earlier in this class, it is during "jsp directive", i explained in "jsp directive" that we could include a page in my main page and where you would usually use this probably you can say you can have certain common features in every jsp page like a header or footer you can use those kind of things to include in your main jsp page. So every page a will have a same header or footer.
Difference between include directive and include action
----------------------------------------------------------------------------------------------------------
include directive include action
------------------------------------------------------------------------------------------------------------
1. Translation Time Run time
2. Copies the included file References to the included file
3. For static content For dynamic content
4. can not pass parameters can pass parameters
--------------------------------------------------------------------------------------------------------
1. Translation Time:
Basically the page included means included your main jsp page at translation time, that means whenever your jsp translated to a servlet at that point of time even the included jsp pages content is got into the main jsp page and then it is tanslated to a servlet.
1. Run time:
It is not done at translation time so even though your servlet, eventhough your jsp translates into servlet it does not really content the included jsp content in the main page but it gets the content at run time when you execute that page
2. copies the included file:
Because it done at translation time it is simply copies all the content from your included page to main page
2. References to the included file:
Since we did not do at translation time simply keeps the included page at its own path and it has some kind of link or reference in the main page where it points to this included page and it craps this content of the included page at that run time and then populates.
3. static content:
including the translation time itself, this is more likely to use for static content, because like for example that your sub page has changed but your main has not changed and if you go and try to give this page again you wont see the latest change made in your sub page because the static content included page content was included in your main page at translation time and translation happens only once and it happens at first time and it happens whenever you changes your main page. Since you didnt make any chages in your main page, no translations happens again that means same static content present in your main page.
3. For dynamic content:
It gets the contents of the included page at run time, you can use it for dynamic content, lets say that your included page is being modified frequently, it used in lots of pages but again it is being modified frequently in that case you go for dynamic content because you dont have to really compile and change your main page so that your included page is , new content page can be reflected.
No comments:
Post a Comment