• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Setting bean in Simple tag attribute

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to HFSJ i am trying example on page 521.
I tried the following but my jsp shows nothing. it comes out blank.Please help dear intellects


JSP that uses tag :



the tag handler:



the object to be set as attribute:



TLD file for tag :



 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are mixing up Scriptlet variables with EL variables.
These things are not the same.

${movieCollection} does not refer to your scriptlet variable movieCollection, but is rather looking for an attribute of that name.
ie the java equivalent of ${movieCollection} would be pageContext.findAttribute("movieCollection");

One solution (for this example page)
add this to the end of your <% scriptlet %> section where you define the list of movies:



This puts the movieCollection variable into the page attribute space where your EL reference can then find it.

 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Although, using scriptlets at all in your JSP pages is not recommended.

And mixing scriptlets with JSTL and EL is even less recommended,

If you are going to use scriptlets (not recommended) then just use scriptlets. Mixing scriptlets with JSTL/EL is just a big old mess.
 
Harshvardhan gupta
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do I also need to specify the type for attribute movieList as java.util.List in the TLD file?
 
Greenhorn
Posts: 10
1
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Harshvardhan
I'm on the same page in HFSJ :-)
Apart from what can be learned from the other answers, it caught my eye that your javaBean lacks getter/setter for the name attribute.

I just tried it out on Jetty; it says "The class 'foo.Movie' does not have the property 'name'". I don't know if e.g. TomCat are more lenient.

Cheers and good luck

Tex Martin
 
Harshvardhan gupta
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you are absolutely correct my friend . Actually initially when i started trying it my intentions were to make it a bean . But i just ended up with trying a normal object which could be set in tag attribute . so it cant be called a bean without getter and setter but atleast i needed to check whether any random object can be set in attribute value . thanks and regards
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic