Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

new instance per user

 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have some idea, anydody please suggest how to implement this.

In any web application or enterprise application, to handle many users
I like to design a context or platform which is unique for a user ,no users can see others context ,Each context has unique context ID, to access the context ,ID should be gven. In context I will place the data which is not intended to share with others. If many users access the same object then ,new instance should be created ,then placed in the particular context.

Please suggest any plus and negative of this ?
 
Uli Hofstoetter
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ii might be missunderstanding you, but you are describing something quite similar to a HttpSession..

Maybe you should dive deeper into the Servlet API before reinventing the wheel.

Regards,
Uli
 
Campbell Ritchie
Sheriff
Pie
Posts: 49382
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is servlets, you should start with our servlets forum FAQ.
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also take a look at the Java EE Tutorial's section on The Web Tier which discusses Servlet's and the life cycle of a client (i.e. a user). From there you can look at one of the many fine Java Servlet/JSP books on the market.
 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but you are describing something quite similar to a HttpSession..

yes I agree ,But expert suggest me that do not use Http session object or use as less as possible.So I forced to take that concept.
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jacob deiter:

yes I agree ,But expert suggest me that do not use Http session object or use as less as possible.So I forced to take that concept.


Sorry, but I have to ask what "expert" suggested this? What were his/her reasons for not using the Java HTTP Session API?

Why would you not want to use an API that has been successfully used, tested, documented, and perfected by millions of developers worldwide to do exactly what it is you want to do? An API written by experts in the HTTP protocol and RFC. An API that mutibillion dollar enterprises run their business off of. An API whose functionality you get for free in any of the dozen or more Java EE compliant web and application servers. Why would you -- or the expert advising you -- think it would be easier or better to write your own code to handle this complex task? Why would you want to spend the time doing such?

I can guarantee you that all the experts on this forum (including myself) would advise you to use it and not to try and write your own. Start a thread in the Servlets forum asking that question and see what results you get.

The other advantage to using the Java HTTP Session API is that when you need to bring additional developers onto the project to help (or turn it over to them), they are far more likely to know the HTTP Session API than a custom one you have written. This only makes sense. And if they don't know it, there are dozens of books and tutorials they can reference rather than you having to document and teach them the API you wrote. In other words, it will make your application easier and cheaper to support and maintain. You always want to think about the long term implications of the design decisions you make.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic