• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Madhu babu Janjanam
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.
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • 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 .

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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 Java Windows XP
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic