What is the difference between , pagedirective include, action tag include ?

Questions by sadashivarao   answers by sadashivarao

Showing Answers 1 - 23 of 23 Answers

prabhaker

  • Apr 8th, 2006
 

Hello,

PageDirective include will execute at the time of Jsp Translation Phse,Means at the time of Compilation.

Action Tag Include will execute at Run time.

Dynamic page execution will occur by using Action Include tag. 

  Was this answer useful?  Yes

Madhavikari

  • Apr 17th, 2006
 

One difference is while using the include page directive, in translation time it is creating two servelts.

But, while using the include action tag, in translation time it is creating only one servlet.

  Was this answer useful?  Yes

ajay

  • Apr 18th, 2006
 

Hi madavi,can u expalin u'r answer with more detail

  Was this answer useful?  Yes

ashish

  • Apr 18th, 2006
 

Hi Ajay, Madhvi i right because include directive generates two servlets one for mane jsp and another for included jsp.

  Was this answer useful?  Yes

Akshay

  • Apr 19th, 2006
 

Ashish

I think include action element generates tow diff't servelets ...ok

  Was this answer useful?  Yes

Madhavikari

  • Apr 20th, 2006
 

when we r using the include directive, it will be translated at the compile time. Means, first time only it is translated the jsp file can be converted into servlet. But, while using the include action tag at runtime it is converting into servlet and then it is using theat servlet and control back to main jsp. SO, in this case only one servlet will be created.

  Was this answer useful?  Yes

satheesh kumar.sriramaneni

  • Apr 20th, 2006
 

Include directive , the process can be done at compilation time. and here we can see only one servlet. Any modifications in the header,we need to recompile the servlet.

Action include: The process can be done at client request time.and here we can see more than one servlet.Any modification in the page ,no need to recompile the servlet.

  Was this answer useful?  Yes

soorma

  • Apr 24th, 2006
 

the diffrence is :

1. <jsp:include page=""/>

   <% @ include file="" %>

2 Run time / Request Time

  Translation time/ Compilation time

3 create 2 servlet

  create 1 servlet

4 Include page field n method not effect the main page

  In this case effect the main page

5 No need to upadte main page after include

  updation required

 riteshyadav14@rediffmail.com 

  Was this answer useful?  Yes

Include Page Directive

Include Action Tag

1. includes static content at compile time

1. action include includes static or dynamic content at run time

2. if the file includes static text 
if the file is rarely changed (the JSP engine may not recompile the JSP if this type of included file is modified) 
if you have a common code snippet that you can reuse across multiple pages (e.g. headers and footers) 

2. content that changes at runtime 
to select which content to render at runtime (because the page and src attributes can take runtime expressions) 
for files that change often 
 

 

3. Sy. <%@ include file=?filename? %>

3. Sy. <jsp:include page:?URL? >

4. after inclusion any change in source file will not reflect the jsp.

4. after inclusion if there any changes in source file will reflect in jsp

5 we are using page directive in the application it means it is going to include that into the page at translation time

5. where as when ever we are using standard action it is includes the page at runtime

6. in translation time it will create 2 servlets

6. in translation it will create only one servlet.

7. it is evaluated only once at translation time.

7. it is evaluated with every request.

8. parsed by container.

8. not parsed, but included in place the specified url is specified at runtime as a separate resource.  The included url may map to a servlet rather than a jsp.

9. use it if our resource is not going to change frequently

9. use it when the resource changes frequently or is dynamic.

10. the attribute of page directive is ?file? and values is ?filename?

10. attribute of action include is ?page? and values is ?URL?

if u have any technical doughts pls contact me on shiva_nspf@yahoo.com

cheers

sadashivarao

infosys,blore

  Was this answer useful?  Yes

sirisha

  • May 18th, 2006
 

 i want to know what is the difference between page directive include action tag include

  Was this answer useful?  Yes

Vibs

  • Apr 27th, 2007
 

Finally whats is correct...include directive will create 2 files and action(jsp inlude) 1 file?

I think include directive should create 1 file cause, it created at the compilation time and because of that only we have to compile the main file again if there is change in only included file.

While in Jsp include action, since its included at run time..there should be 2 separate files...and hence the one changed is only compiled again.

Let me know if wrong

  Was this answer useful?  Yes

I will make it clear...

Include directive...

All the files are included at the compile time so there is only one servlet in which all code is included...This makes sense for including static content because we need to compile the servlet again to make any changes...


Incude action..

One file includes other at the run  time...so

so it is almost like calling another JSP using RequestDispatcher... from a servlet


so execution switches to the called Jsp and is cmpiled on the run time and is translated to the servlet ..this is how we have two servlets at the same time in th econtainer...

  Was this answer useful?  Yes

praveen7g

  • Jun 5th, 2008
 

page include is called as static include because at the time of the compilation the jspc
 will compile the two jsps and make it one jsp and submit to the jvm the jvm executes
only one jsp at the timeof executeion.

incude action is called as dynamic include because at the time of compilation the jspc
will compile two jsps individually  and submit the two jsps to the jvm then the jvm will
combine two jsps and executes it.

here staticinclude is efficient.

  Was this answer useful?  Yes

<% @include file = ""%>
In this case the page will be included at the time compilation.
It is static include.
If you have any changes that will not be reflect ie it will not display the out.


<% @include page =""%>
In this case page will be include at the time excution time ie run time.
It is dynamic.
If you have any changes that will be reflect at the time of display.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions