File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Simple vs Classic Tags - When ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Simple vs Classic Tags - When ?" Watch "Simple vs Classic Tags - When ?" New topic
Author

Simple vs Classic Tags - When ?

Sreedevi Vinod
Ranch Hand

Joined: Jan 17, 2005
Posts: 117
hi, I read the following in a website "Simple tag handlers can be used only for tags that do not use scripting elements in attribute values or the tag body. Classic tag handlers must be used if scripting elements are required."
However, nothing of this sort is mentioned in the K & B book.
Is the above information correct ?
If not, then whats the actual difference between simple and classic tags except that simple tags are easier and simpler to use ? K &B states that classic tags used to be there in the previous version and hence supported. Any other reason such as the one stated above ?

Thanks
Devi
J Johny Rufus
Ranch Hand

Joined: Oct 29, 2003
Posts: 47
Hi Sreedevi Vinod,

The body of a simple Tag is processed as a JspFragment , which can only contain template text and JSP action elements. so, it must not contain scriptlets or scriptlet expressions .
<body-content> for a SimpleTag cannot be JSP and defaults to "scriptless" .
A translation time should occur if the body content contains scriptlets or scriptlet expressions .

whereas,

a classic Tag doesnot have this restriction as its body is processed as BodyContent which is a subclass of JspWriter .

<body-content> for a ClassicTag defaults to "JSP"

Thanks and Regards,
Rufus
shiva viswanathan
Ranch Hand

Joined: Aug 12, 2004
Posts: 152
HI Rufus ,
As you said
The body of a simple Tag is processed as a JspFragment , which can only contain template text and JSP action elements. so, it must not contain scriptlets or scriptlet expressions .


Can it contain EL expressions since scriptless body content means
it can contain standard actions and EL expressions ?

Thanks
Shiva
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

It can contain template text, EL, Standard and custom actions.

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
J Johny Rufus
Ranch Hand

Joined: Oct 29, 2003
Posts: 47
Hi Shiva,

I perfectly agree with Narendra, as "Scriptless" bars the usage of two things

1. scriptlets <% %> and
2. scriptlet expressions <%= %>

Thanks and Regards,
Rufus
Sreedevi Vinod
Ranch Hand

Joined: Jan 17, 2005
Posts: 117
Thanks for your replies. Can you also tell me, any cases where we would prefer to use simple tags instead of classic tags ?

-Devi
[ July 25, 2005: Message edited by: Sreedevi Vinod ]
sergio mendez-rueda
Ranch Hand

Joined: May 12, 2005
Posts: 37
Originally posted by J Johny Rufus:
Hi Shiva,

I perfectly agree with Narendra, as "Scriptless" bars the usage of two things

1. scriptlets <% %> and
2. scriptlet expressions <%= %>

Thanks and Regards,
Rufus

und what is about this <%! String Hi_you_declaration!!! %>
compile or not compile??
Brian Percival
Ranch Hand

Joined: Jun 23, 2004
Posts: 163
when they say no script is allowed, I would think anything which starts like <%...
is not allowed.

Now that makes me wonder if a jsp comment is allowed.. like
<%!-- ......

any comments?

regards,
Brian
sergio mendez-rueda
Ranch Hand

Joined: May 12, 2005
Posts: 37
Originally posted by Brian Percival:
when they say no script is allowed, I would think anything which starts like <%...
is not allowed.

Now that makes me wonder if a jsp comment is allowed.. like
<%!-- ......

any comments?

regards,
Brian

Hi,
scripletless means:
no declaration, expresion or scriplet
but <%-- this is a comment --%>
This is a comment.
O.k?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple vs Classic Tags - When ?
 
Similar Threads
Scripting inside tag body
JSP Implicit variables in tag files
Final Mock Exam question 19
using scripting with standard jstl tags
Taghandler initilization by the jsp container