Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing object from jsp to java class

 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

How do I pass an object from jsp to my java class using input tag or something else. Currently I have the follwoing code

<input name="editQuestion" type="image"
src="images/edit.gif"
alt="Edit Question"
title="Edit Question"
onnClick="setAction('editQuestion', 'surveyQuestion.do?surveyQuestion.surveyName&surveyQuestion.sequence&....)

I actually want to be able to pass the while surveyQuestion object. How do I do that.
Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't. Firstly, any object that is in scope while the JSP is executing on the server goes out of scope as soon as the response is sent to the client.

Secondly, the HTTP protocol limits you to submitting strings as request parameters via a form submission. No objects -- no nothing, except strings.

Perhaps this article on the life-cycle of JSP pages will help you understand these concepts.

If you want/need a server-side object to have a scope greater than the lifetime of the current request, you will need to explore alternate means to do so. Perhaps as a scoped variable in session scope?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic