This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes include directive -> Can include web component? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "include directive -> Can include web component?" Watch "include directive -> Can include web component?" New topic
Author

include directive -> Can include web component?

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
In HD Book [p-220], it's mentioned that include directive can include any web component in a JSP page.

However when i tried to include a servlet (using include directive), it gave me a error.

org.apache.jasper.JasperException: /jsp/JSP_Static_Include.jsp(9,3) File "/SV_MyInitServlet" not found
Hendy Setyo Mulyo
Ranch Hand

Joined: Dec 01, 2004
Posts: 219

Is it because Servlet not a static resource? Include directive can only used for static resource.


Hendy Setyo Mulyo
SCJP 1.4 (95%), SCWCD 1.4 (94%)
Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
Yups you are right :

Static include -> Static resources -> Contents
Dynamic include -> Dynamic (+Static) resources -> Output
Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
Hendy,
By the way JSP is also not a static resource.
Still i can include JSP with include directive.
Rancy Chadha
Ranch Hand

Joined: Jul 12, 2006
Posts: 135
Sandeep,

You can use JSP with include directive because the content of the included JSP is copied in the calling JSP. For e.g I have a Jsp:
a.jsp->
and I include it in b.jsp:

The code of the b_jsp.java will be something like this:
out.print("<html> <body>");
out.print("Dear User...");
out.print("<h1> Welcome to my page </h1>");
out.print("</body></html>");
Thus the code from a.jsp is merely copied in the resulting java file of b.jsp. You can also take it as, source of jsp is included in the calling jsp page.
I hope it is clear to you now, why jsp being dynamic can be used with include directive and why servlet cannot be used.
[ May 07, 2007: Message edited by: Rancy Chadha ]

Thanks,<br />-Rancy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: include directive -> Can include web component?