File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes passing object from jsp to java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "passing object from jsp to java class" Watch "passing object from jsp to java class" New topic

passing object from jsp to java class

Muhammad Imad Qureshi
Ranch Hand

Joined: Sep 13, 2005
Posts: 238

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"
alt="Edit Question"
title="Edit Question"
onnClick="setAction('editQuestion', '

I actually want to be able to pass the while surveyQuestion object. How do I do that.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

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?

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: passing object from jsp to java class
It's not a secret anymore!