File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes jsp second request also make new object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp second request also make new object" Watch "jsp second request also make new object" New topic
Author

jsp second request also make new object

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
this is my jsp filw


i ma using netbeans
when i run this file it shows output " INN OUT".
But i copy and past the url in a new tab.then also it gives same output.
when second request comes it doesnt creat a new object of person.so it must give old object values.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61417
    
  67

The requests are distinct and separate. A new Person object will be created for each request.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
that means if one client send a two request to the jsp it creates two instance for that requests.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61417
    
  67

It doesn't matter where the requests come from. Each is a distinct and separate request and the way that JSP is written, a new Person instance will be created for each and every request.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
This is because you're using a scope of request. If you want the same instance for all requests made by the same user, you probably want to use a scope of session.

Otherwise, I'm not understanding what you're asking (your post title is a "statement", not a "question").

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp second request also make new object