Actually... for performance, the first one is best. Why?... as when the 
main page is compiled, the files included by this method are included as 
if they were written in the one file, and then compiled. If a change is 
made to the include, it wont be picked up unless the main page is 
changed/recompiled for some reason. As it all ends up being the same 
page, this is faster performance wise when everything is compiled and 
dancing (C&D? :).

For flexibility, the second. This method will create a servlet for each 
include, and then pass the context from the first, to the included 
second. Because the servlets have to pass the context and everything, 
this is slower when everything is C&D. The second can also be called 
directly in its own right.

For my money, I usually go the first. Well, at least for any include 
that wont be edited without being able to restart the server. If it 
"needs" to be recompiled, you just touch the main page.

In some instances you "need" that second servlet. Why?... Java's spec 
means that it will only take a compiled class up to 62K (If memory 
serves. It's around there). Some pages we have to make can make this 
quite easily once it's all said and done. So this means you have to use 
the separate servlets. In one case I used the same include on multiple 
pages by creating an empty wrapper JSP which would make another servlet, 
and then include the static include like the other pages, and where 
included use the dynamic include.


More often than not, I go for door number one.
(also cool because it perfectly makes for nesting through to included 
files, so I can have my "view state" files for my nested beans. :)



Arron.


Keith Bacon wrote:

>Hi all,
>I tend to think that 
><%@ include file="my_page.jsp" %> is  bad,
><%jsp: include page="my_page.jsp" %> is best.
>
>Any opinions on this?
>If you change an included file I assume all the jsp's that access it are recompiled 
>next time they
>are used (or can be manually recompiled). Which could be very slow.
>Included pages get recompiled, but not the page that includes them ie. only the thing 
>you change
>gets recompiled.
>Is this right?
>
>Keith.
>
>--- Arron Bates <[EMAIL PROTECTED]> wrote:
>
>>The type of include you're using here is a dynamic include. Meaning that 
>>the page to be included isn't simply added, it's compiled into its own 
>>servlet, and the page's context is passed to the included servlet. For 
>>the tags to work in the included servlet, they need all the taglib 
>>imports like your original JSP would.
>>
>>Or you can try the other form of include, which simply takes the file 
>>and puts it in the larger file when the JSP is compiled (this is the 
>>behavior it seems you are expecting)...
>><%@ include file="my_page.jsp" %>
>>
>>
>>Arron.
>>
>>Bryan P. Glennon wrote:
>>
>>>Hi -
>>>   This is really more of a JSP question, but since it involves struts
>>>tags I figured I'd give it a shot here. I have a page which contains a
>>>form built using the html:form taglib. Based on the users selection from
>>>that form, I go off and do some processing and redirect the user back to
>>>the same page. During the processing, an attribute gets set to indicate
>>>which detail information to include. I try to include this detail page
>>>(which is also an html:form form) by doing a jsp:include.  Basically,
>>>the page looks like this:
>>>
>>>     <html:form...>
>>>             Navigation form
>>>     </html:form>
>>>
>>>     Static stuff here
>>>
>>>     <jsp:include page="<%=detailPage%>" />
>>>
>>>     My problem is that the tags in the included page never get
>>>processed. So, is there anyway I can make this work?
>>>
>>>   Sorry again for the OT post.
>>>
>>>Cheers,
>>>Bryan
>>>
>>>--
>>>Bryan Glennon (mailto:[EMAIL PROTECTED])
>>>BPG Consulting, Inc. (http://www.bpgc.com)
>>>Tech Question? (mailto:[EMAIL PROTECTED])
>>>
>>>--
>>>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>>>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>>>
>>>
>>
>>
>>--
>>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Great stuff seeking new owners in Yahoo! Auctions! 
>http://auctions.yahoo.com
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to