• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

useBean: Duplicate bean name

 
giang nguyen
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider:
<html><body>
<%{%>
<jsp:useBean id="address" class="AddressBean" scope="session" />
<%}%>
<jsp:useBean id="address" class="AddressBean" scope="session" />
<jsp:getProperty name="address" property="street" />
</body></html>
Note that the first <jsp:useBean id="address" is in a pair of curly braces, and to my knowledge I think that this action will create a variable adress which is valid only within the scope of the pair of curly braces. Therefore, the variable created by subsequent action although has the same name should be valid because the first variable is in the curly braces scope.
I don't understand why servlet container give translation error when encountering this. Can any one explain?
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which JSP container did u use? I guess Tomcat. But the code will be ok for WebLogic... U might want to have a look in the following thread about the exact question that u asked...
http://www.jdiscuss.com/Enthuse/jsp/ViewPosts.jsp?forumid=26&topicid=818
 
giang nguyen
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ko Ko Naing:
Which JSP container did u use? I guess Tomcat. But the code will be ok for WebLogic... U might want to have a look in the following thread about the exact question that u asked...
http://www.jdiscuss.com/Enthuse/jsp/ViewPosts.jsp?forumid=26&topicid=818

Thanks for your reference.
Now I understand that this is container specific. Actually I used websphere to test this when I doubted the question. According to those guys in jdiscuss with weblogic this is ok. I myself think that the way that weblogic implement is more logical and close to specification.
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome... It's pleasure to help people out here and share the knowledge each others...
It's good that I'm a big fan of WebLogic, which implements thing closest to the specifications... But I do know that WebSphere also has its own goodness, which WebLogic doesn't have...
 
David Swan
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
straight from the SCWCD book,
a translation-time error will occurr if the same "id" is used within a translation unit...
so maybe this applies regardless of whether the braces bring it out of scope or not!!
Regards
Dave
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David Swan:
straight from the SCWCD book,
a translation-time error will occurr if the same "id" is used within a translation unit...
so maybe this applies regardless of whether the braces bring it out of scope or not!!
Regards
Dave

But in Java, it is legal to declare the same id using the braces... So I'm sure whether to apply the usage of Java Language or the usage in the servlet specification...
[ December 10, 2003: Message edited by: Ko Ko Naing ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic