This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

An application scope attribute is output as null  RSS feed

 
Himai Minh
Ranch Hand
Posts: 1510
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From chapter 10 of Murach's book,
I have a ProductTag class:

In murach.tld :


In index.jsp:




My question is the pprice , which is product price is null even though it is application scope. But the product description is not null.
Why?

cdList.PNG
[Thumbnail for cdList.PNG]
Price is null
 
Himai Minh
Ranch Hand
Posts: 1510
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I modified the above ProductTag:


The initial product price is null while the rest of the product prices are printed. Why?
cdList.PNG
[Thumbnail for cdList.PNG]
 
Himai Minh
Ranch Hand
Posts: 1510
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now, I figure out why.
I improved my code:

In index.jsp:


If the scope is session, then use session.getAttribute("pprice"). If the scope is page, then use pageContext.getAttribute("pprice").
It works now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!