• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

include directive -> Can include web component?

 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it because Servlet not a static resource? Include directive can only used for static resource.
 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yups you are right :

Static include -> Static resources -> Contents
Dynamic include -> Dynamic (+Static) resources -> Output
 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hendy,
By the way JSP is also not a static resource.
Still i can include JSP with include directive.
 
Rancy Chadha
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic