Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Get Object in JSP help . . . . . . .  RSS feed

 
Hyder Ali
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Hyder Ali
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!