Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5942311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:14:07+00:00 2026-05-22T16:14:07+00:00

I will try to be short and most specific. It is possible to create

  • 0

I will try to be short and most specific. It is possible to create class, class property or “something” which will be created for each request ? I mean something what will not be persistent for whole container (static class property).

I need to store internal identifier into class or property, which will be diferent for each request and persistent for whole request. I’m using java filters and before doFilter I need to save that identifier “somewhere”. Because I need to use that identifier in application for some operations. And after doFilter I need to take that identifier from “somewhere” and update some other things.

Thanks for any advice how to solve this problem …


Edited 24th May 2011 10:25 am

Ok, I will try to explain my problem closely.

I’m using Tomcat 6 with BlazeDS utils. This server is working as backend for a flex application.
So, if I want to send some messages or object or whatever else to server I just call something like this:

service.doSomethingWithThis( data )

In flex is the “service” property mapped to class, eq. “foo.bar.BazService” and this service has method “doSomethingWithThis” with parameter “data”. And when request is recieved by server then “doSomethingWithThis” method is executed with parameter “data”.

public int doSomethingWithThis( Object data ) {
  GenericDAO genDao = new GenericDao();
  genDao.create( data );
}

So, as you can see, I don’t have access to the request property. What I call at Flex side it is called on Java side.

Another problem is with that DAO object (in this case GenericDAO). Those DAO objects are little bit specific. They are asking for database connection and this connection is provided by a singleton Class, which holds database connection for the whole application. So, I’m not passing connection parameter to DAO objects as is usual, but they are asking for that connection themselves. I know that it is not the right approach :).

Now we are trying to fix this problem and we want to use pooling database connection, which is provided by Tomcat. And there is problem. If I retrieve connection I need that connection put back to the pool. But my DAO objects are not closing database connection. Solution can be to pass connection parameter to DAO objects when service method is called and at the end close that connection, but I have a lot of services and it is a lot of refactoring. So I’m trying to find an another way, when I will be able to encapsulate whole request (Java Filters) and store database connection “somewhere”. And my DAO Object can take this connection from “somewhere” place.

Store database connection in request is one solution, but as you can see, I don’t know how to access this request in my DAO classes, or service classes. Other way is to use session, but there is also problem. There can be multiple requests to server and first request which will be completed will close that connection. So, other requests can not use that database connection anymore, because it was returned to pool.

So I’m targeting for solution, when I will be able to get one database connection for the whole request.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:14:08+00:00Added an answer on May 22, 2026 at 4:14 pm
    request.setAttribute("name", variable);
    

    will persist for the lifetime of the request, and no longer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will try and illustrate my question with examples, I am attempting to create
I will try to be as clear as possible because I can't get anybody
I will try to keep this as simple as possible. I have a rather
I will try and keep this short and to the point. Given the following
I will try to explain the situation as it is a little bit more
I will try to make this as clear as I can, but if you
I will try to explain a simple app scenario: My app goes right to
Quite often I will try and run a PHP script and just get a
First I will try to explain what I want to do. The app loads
I am working on an algorithm that will try to pick out, given an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.