• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

scope="application" problem

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I'm a JSP starter and encountering a problem I can not understand.

index.jsp:
testClass.java:

I want to impelent an application-wide data storage.

On the first call of my JSP everything works correct. But on any following calls there seem to be problems loading testClass:
Everything between <jsp:useBean ...> and </jsp:useBean> is just ignored ( this is tested ).
No error message is printed in the browser or in the GlassFish logs. I'm just getting my empty page.
What am I missing?

Thanks!!!

 
Sheriff
Posts: 67637
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
Why do you have anything in the body of the useBean action?

The useBean action tag should be self-closed except in the case where it will enclose setProperty actions to initialize bean properties (itself a rather deprecated practice).
 
Johannes Salter
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Why do you have anything in the body of the useBean action?

The useBean action tag should be self-closed except in the case where it will enclose setProperty actions to initialize bean properties (itself a rather deprecated practice).



In fact I'm doing some getProperty-Requests in the body.

However...this should be executed every time the JSP is requested.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your markup doesn't need to be inside the useBean tags body.

As Bear said, the only thing that should be in the body are setProperty tags.
These will be called only when the bean is instanciated (which is once if you use scope appplication.

The useBean tag does some interesting things. It's a good idea to read the section on it in the JSP spec.
There is a link in my signature.
 
Johannes Salter
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yay!

Working like a charm.
You have my thanks!
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic