• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to send my object reference from .jsp to .class

 
Caglar Cataloglu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I have a jsp page that shows a preview of an article before submitting and saving into database. I have come good so far but now on the last step, i need to send my JavaBean object which is already being shown on the .jsp page to my servlet or any java class in order to save it into database, but i do not know how to send that object reference.

Here is my preview page, and after clicking a button i want to send object reference (Article) to a java class method as a parameter.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65528
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Caglar Cataloglu wrote:i need to send my JavaBean object which is already being shown on the .jsp page to my servlet or any java class

You can't. Once the JSP is done executing and the response is sent to the browser, the bean is gone and is likely to have been garbage collected.

Please read this article to understand how JSP works.
 
Caglar Cataloglu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Caglar Cataloglu wrote:i need to send my JavaBean object which is already being shown on the .jsp page to my servlet or any java class

You can't. Once the JSP is done executing and the response is sent to the browser, the bean is gone and is likely to have been garbage collected.

Please read this article to understand how JSP works.


Thank you for your reply. I have started to read that article.

I think i need to change my business logic if i lose my object entirely after response.
did you experience a situation like this and if you did how did you solve.

Regards
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The usual approach would be to save a reference to the object in the HttpSession where it will be recoverable by any servlet in the same web application.

Bill
 
Caglar Cataloglu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:The usual approach would be to save a reference to the object in the HttpSession where it will be recoverable by any servlet in the same web application.

Bill


Good idea, i will try that in the near future.

I have solved my problem by using hidden divs and parsing input values again in hidden divs.

Thanks a lot.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!