This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

How to maintain a global variable in the entire jsp web application.

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I am Madhu, I am having a jsp web application which uses a set of classes. my problem is I want to call a class for every 10000 requests coming to the web application.

thankx in advance.
 
Bartender
Posts: 4106
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the application scope to store the variable.

Something like,

Full details here

And welcome to JavaRanch .

 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vijitha Kumara wrote:



yes but Nowadays initializing a class in jsp is discourage .so better do your logic with class on servlet. application is nothing but servlet context.

Hope this helps
 
Madhu babu Janjanam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vijitha Kumara wrote:Use the application scope to store the variable.

Something like,

Full details here

And welcome to JavaRanch .




As I am begineer in jsp can you suggest the full length code how to write and maintain the number of requests and after reaching 10000 how to call particular method in a that class.
 
Marshal
Posts: 67293
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the counting has absolutely nothing to do with the actual functionality of your pages, you shouldn't pollute the JSPs (or even servlets) themselves with this stuff. Rather, I'd employ a filter that counts requests (storing the count in application context).
 
Madhu babu Janjanam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Since the counting has absolutely nothing to do with the actual functionality of your pages, you shouldn't pollute the JSPs (or even servlets) themselves with this stuff. Rather, I'd employ a filter that counts requests (storing the count in application context).





how to do this?
 
Madhu babu Janjanam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Since the counting has absolutely nothing to do with the actual functionality of your pages, you shouldn't pollute the JSPs (or even servlets) themselves with this stuff. Rather, I'd employ a filter that counts requests (storing the count in application context).





please help me ASAP..
 
Bear Bibeault
Marshal
Posts: 67293
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked up servlet filters? There are tons of examples and they are very easy to use.

Where's you code? What problems are you having with it?
 
Madhu babu Janjanam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Have you looked up servlet filters? There are tons of examples and they are very easy to use.

Where's you code? What problems are you having with it?




hi I had .jsp page as follows:


with the same code shown above I had remaining 4 .jsp web pages in my web application.

wat I want to do is to call a for the first request to the web application I want to call loadPrimes and selectionofPrimes methods after every 1000 requests I want to call selectionofPrimes method (code is shown in below)


please respond me as soon as possible........
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Madhu babu Janjanam wrote:please respond me as soon as possible........



Patience is a Virtue
 
I'm so happy! And I wish to make this tiny ad happy too:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!