Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

scope="application" problem  RSS feed

 
Johannes Salter
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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!!!

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Yay!

Working like a charm.
You have my thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!