Change data in a bean

A

AllIsPossible

Hi,

Sorry if this is a basic, simple, question :p

I have a bean that retrieves data. I "set a property" for a field in
the bean that I would like to call ("the key") and it brings back the
data I want from the database - yippee!!

Now, I want to change what has been retrieved (using the bean) but it
looks as though before the .jsp is displayed *all* actions associated
with the use of the bean:

<jsp:useBean ...>
<bean:write ...
<jsp:setProperty name="....>

are executed BEFORE the display of the .jsp page (which really turns
into HTML). Is this the case? If so, then the only way that one can
change any data brought into the HTML page is when he/she hits the
SUBMIT button and the page goes to the server? Then, does that mean
that the bean is ONLY good for reading data INTO a page - in other
words, you can come in through the bean but you can't get out through
the bean?

That would be such a bummer :-|

TIA ..
 
T

Tom Dyess

AllIsPossible said:
Hi,

Sorry if this is a basic, simple, question :p

I have a bean that retrieves data. I "set a property" for a field in
the bean that I would like to call ("the key") and it brings back the
data I want from the database - yippee!!

Now, I want to change what has been retrieved (using the bean) but it
looks as though before the .jsp is displayed *all* actions associated
with the use of the bean:

<jsp:useBean ...>
<bean:write ...
<jsp:setProperty name="....>

are executed BEFORE the display of the .jsp page (which really turns
into HTML). Is this the case? If so, then the only way that one can
change any data brought into the HTML page is when he/she hits the
SUBMIT button and the page goes to the server? Then, does that mean
that the bean is ONLY good for reading data INTO a page - in other
words, you can come in through the bean but you can't get out through
the bean?

That would be such a bummer :-|

TIA ..

I'm not really sure what you're asking, but if you want to retrieve user
input from an HTML form, you need to go through either a submit button, or a
dynamicly created querystring with a redirect (which is kinda strange to me
for a form). Either of which need to be clicked and handled by a servlet or
jsp or whatever. That's just web architecture, you can't do much about that
unless you change from a HTML/JS container to an Applet or ActiveX or
something.
 
J

John C. Bollinger

This is not really about Javabeans, and certainly not about databases.
Followups directed to comp.lang.java.programmer.
Hi,

Sorry if this is a basic, simple, question :p

I have a bean that retrieves data. I "set a property" for a field in
the bean that I would like to call ("the key") and it brings back the
data I want from the database - yippee!!

Now, I want to change what has been retrieved (using the bean) but it
looks as though before the .jsp is displayed *all* actions associated
with the use of the bean:

<jsp:useBean ...>
<bean:write ...
<jsp:setProperty name="....>

are executed BEFORE the display of the .jsp page (which really turns
into HTML). Is this the case?

It depends what you mean. In an HTML / HTTP setting, JSP is a
technology for dynamically creating HTML pages in response to HTTP
requests. A JSP runs on the server, and the client only ever sees the
HTML results. (This is much like other web scripting technologies such
as PHP and ASP.) Thus, if you mean that bean manipulation happens
before the browser renders the page on the client then you're right.
If so, then the only way that one can
change any data brought into the HTML page is when he/she hits the
SUBMIT button and the page goes to the server? Then, does that mean
that the bean is ONLY good for reading data INTO a page - in other
words, you can come in through the bean but you can't get out through
the bean?

If you want to modify an HTML page on the client side (without making a
new request to the server) then you need to use a client-side
technology, such as Javascript. Your JSP can very easily output
Javascript code as part of its HTML response.

Beans are useful for a wide variety of things in a JSP, but in that
context they are limited by the servlet request / response model. That
does, however, mean that people without Java-enabled browsers can use
your JSPs.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top