• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request/Translation time confusion

 
Ian B Anderson
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am trying to get the whole included at request/translation time thing sorted out in my head.
This question references the following JWeb+ Question:
ID: 997123036181
Think about the following code:
1) <jsp:include page="file_one.jsp" /> - Request time
2) <%@ include file="file_two.jsp" /> - Translation time
Is this right so far?
JWeb+ also says that the following is included at translation time
3) <jsp irective.include file="file_three.jsp" />
When I try this on Tomcat the following happens
1) The output of the JSP file is displayed. (JSP is processed)
2) The output of the JSP file is displayed. (JSP is processed)
3) This just prints the tag out in the source code i.e. <jsp irective.include file="file_three.jsp" />
Now 1 and 2 I can understand what confuses me is the printing of the tag. (I don't think its a syntax error as there is no parsing error).
I understand that request time means it can take a dynamic filename.
E.g.
<% String fileName ="file_one.jsp"; %>
<jsp:include page="<%=fileName%>"/>
The above will work however the following wouldn't because its translation time:
<%@ include file="<%=fileName%>" %>
My question is whats going on with part 3?
Thanks in advance
Ian
[ PS : Ajith disabled smilies in the post. UBB tries to interpret certain letter patterns starting with : as a smiley ]
[ February 20, 2002: Message edited by: Ajith Kallambella ]
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, let me try..
<%@ include file /> and <jsp directive.include file /> do the same thing. They include the raw content of the referenced file as the source, as though the content has been actually typed into the source text. Think of this as a macro substitution. This is typically used for static includes. I understand this can also be used for including raw bytes such as images. ( Please correct me if I'm wrong )
<jsp:include file /> on the otherhand, is called the include action. Unlike the include directive which streams in the unparsed content from the included file, the include action actually "executes" the target jsp file and includes the ouput produced into the source. Naturally this is much more powerful than the include directive. The include action is typically used to include dynamic content such as other jsp files( and servlets? ).
Feel free to correct me/add more.
[ February 20, 2002: Message edited by: Ajith Kallambella ]
 
Ian B Anderson
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
OK I think my examples are confusing me here.
Out of the three examples above, one and two I can understand but by putting the following code in a JSP page:
<jsp:directive.include file="file_one.jsp" />
It translated too:

// end
// HTML // begin [file="/dynamic.jsp";from=(10,34);to=(16,0)]
out.write("\r\n\r\n<jsp:directive.include file=\"file_one.jsp\" />\r\n\r\n</BODY>\r\n</HTML>\r\n");
// end
It doesn't include any content from that file just outputs the actual tag.
I'm using Tomcat 4
Any ideas why its doing this?
Ian
 
Jignesh Malavia
Author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is printing the tag in the output because you are mixing JSP syntax with XML syntax. You can either use XML only:

or use JSP syntax only.
JSP will not, in many cases, complain about XML, but XML syntax will not allow any JSP tags.
Hope that helps!
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) <jsp:include page="file_one.jsp" /> - Request time
Additionally, the include action can support params. So you couild say....

- satya
[ February 21, 2002: Message edited by: Madhav Lakkapragada ]
 
Ian B Anderson
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Thanks for that its all working as expected.
Cheers
Ian
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic