aspose file tools
The moose likes JSP and the fly likes Get Object in JSP help . . . . . . . Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Get Object in JSP help . . . . . . ." Watch "Get Object in JSP help . . . . . . ." New topic
Author

Get Object in JSP help . . . . . . .

Hyder Ali
Greenhorn

Joined: May 10, 2002
Posts: 5
hi,
how can we get an object which is returned form any Geter mathods in jsp.
like:
Hashtable ht = <jsp:getProperty name="obj" property="getHt" />
that is totaly worng.
I do not want to used SESSION object.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Hyder
The getProperty tag is used to get the value of a property of a bean. It doesn't really return anything it just prints whatever is returned to the HTML page being formed.
If you have a bean however that has a getXXX method that returns an object then you can just use something like this:
Hashtable ht = beanName.getHashtable();
Where beanName is the name of the bean as you defined it in the useBean tag and the getHashtable method is a method in the bean that returns a hashtable.
IS that what you were looking for? The only other thing I can think of that is related would be storing objects in the request or in the session (but you dont want to use the session for some reason). You can store objects in the request or the application (servlet context).
hope that helps


Dave
Hyder Ali
Greenhorn

Joined: May 10, 2002
Posts: 5
Hashtable ht = beanName.getHashtable();
yes! I can use the above-mentioned code.
But I created instance by <useBean> tag in varify.jsp
and request forward to retry.jsp there want to use Hashtable object, that made in bean.
I can get the getProperty in retry.jsp but not object.

[ June 06, 2002: Message edited by: Hyder Ali ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56150
    
  13

Hyder, please correct me if this is not an accurate representation of your question:
You create an instance of a bean via the jsp:useBean tag in your first JSP (and I am assuming that you are using request scope). Then you forward to another JSP from this first page and wish to access the same instance of the bean.
Correct?
If so, you can simply repeat the jsp:useBean tag in the second page with the same name, class and scope and it will pick up the bean from the forwarded request.
The reason this works is that when the first jsp:useBean tag is encountered it creates an instance of the bean and places it as an attribute in the request scope (if that's the scope you specified). But, if an attribute of that name (and appropriate type) already exists on the request, it will simply get "attached" rather than replaced.
hth,
bear
[ June 06, 2002: Message edited by: Bear Bibeault ]

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get Object in JSP help . . . . . . .
 
Similar Threads
UseBean
question on implicit objects in EL?
implicit objects
implicit objects from page context
How to pass a Post parameter using a link?