• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Example on use of String as a java bean ??

 
Rohit Kelkar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a good example on the use of java.lang.String as a possible class attribute in a java bean.
Thanks in advance.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The statistics section of the F.A. Premier League web site contains several links back to the main site running on a different host. To avoid hardwiring the hostname in the JSPs, an initialisation servlet pulls this information from the web.xml file and binds it as an application-scoped java.lang.String object.
The JSPs declare this String using <jsp:useBean>, so that in the remainder of the JSP you can refer to it as <%= mainsite %>. You could avoid using scriptlets by either wrapping this String inside a bean, enabling you to use <jsp:getProperty>, or by creating a little tag that writes the site location. But there were only a handful of JSPs that needed to link back and second, there are places where you can't use a tag (scriptlets for instance -- thank God that JSP 2.0 will integrate a proper expression language in the container).
- Peter
[ November 03, 2002: Message edited by: Peter den Haan ]
 
AJAY RANA
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for such wonderful replies Peter !
Regards,
Ajay Rana
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic