File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes tagdependent in tag files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "tagdependent in tag files" Watch "tagdependent in tag files" New topic

tagdependent in tag files

Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
<%-- WEB-INF/tags/body.tag --%>
<%@ tag body-content="tagdependent" %>
Start <jsp:doBody /> End

<%-- output.jsp --%>
<%@ taglib prefix="ayo" tagdir="/WEB-INF/tags" %>
<% request.setAttribute("position","Middle"); %>
<html><body><ayo:body><%= request.getAttribute("position") %></ayo:body></body></html>

Answer:"Start End"
Reason: body-content is tagdependent, so it allows scriptlets, which is not evaluated.So no exception thrown.
My question is: tagdependet treats body content as simple text. In this case, shouldn't the answer be "Start <%= request.getAttribute("position") %> End"?

"There are no dumb questions" quoted from HFSJ. "To err is human; to forgive is divine"
Fabian Angy
Ranch Hand

Joined: Oct 27, 2008
Posts: 90
On this post, you can see that you can have scriptlet inside the body of a tag file but they are ignored when you call "<jsp:doBody/>".

Correct me if I'm wrong.

Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
So in this case, scriplets are neither evaluated, nor output as simple html text. Thanks for the answer.
I agree. Here's the link:
subject: tagdependent in tag files
It's not a secret anymore!