• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use the bean Object

 
Goldie Hawn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
when I create the bean object using the following code
<jsp:useBean = "book1" scope="session" class="myClass.Books" />
How can I pass this object book1 as an hidden type request parameter to another html page.
Is this the right way to do it?
<input type=hidden name="book" vaue=book1>
Thanks in Advance
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The naming policy States : "Do not use the names of celebrities."
Please reregister with a nmae that meets http://www.javaranch.com/name.jsp
 
Bharatesh H Kakamari
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the HTML page is being called by the same page where the bean instance (<jsp:useBean> action is defined then there is no need to pass it as hidden field as you have already given a "session" scope.
Also note that the syntax should be:
<jsp:useBean id="book1" scope="session" class="myClass.Books" />
HTH
 
ken chou
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

<jsp:useBean id="book1" scope="session" class="myClass.Books" />
For the above, you define the bean "book1" with the scope of "session", you can always get the same bean as long as it's in any page with the same session. For the following:
<input type=hidden name="book" vaue=book1>

You define a hidden Variable named "book" with a String value "book1". It will be totally different thing since it's not a bean.

 
hemang patel
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try changing the scope of the bean to application. Then, you can use the same bean in the html if that html is a part of the application ....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic