• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

An application scope attribute is output as null

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • 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: 1361
7
  • 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: 1361
7
  • 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