Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Tag Attributes

 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Consider the following code.
<html>
<body>
<%@ taglib uri="ClassicTags" prefix="test" %>
<%
pack.Student student=new pack.Student();
request.setAttribute("student",student);
%>
<jsp:useBean id="student" class="pack.Student" scope="request" />
<test:classic attrib="student" />
</html>
</body>
Question is, whether the object of type Student will be passed to the tag handler or not.
Answer for the above code is No. String student will be passed to tag handler.
can anyone explain how this will happen? why the object of Student is not passed.

Thanks and Regards,
 
Senthil Kumar
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as far as i know bean reference created in useBean will be valid only for the
setProperty and getProperty.

Instead of jsp:usebean you can directly give like this

<test:classic attrib="${student}" />
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!