Link to home
Start Free TrialLog in
Avatar of Gar04
Gar04

asked on

Populating a html form using jsp resultset and then forwarding from data to a bean??

hey
i just wanted to know if it is possible to populate a html form with data retrieved from a jsp resultset (quering a database)
and then on the form submit, have that parsed to a javabean
for further processing
i have tried several other methods and none work correctly
like:
<%
        String siteId = rs.getString("SiteID");
        Bean5.setSiteId(siteId);
%>
      <td height="10"><div align="center"><%= siteId %></div></td>

what would i do if i put the value "siteId" in a textfield and then sent it to the bean called Bean5 above????
what is the correct code for this??
Gaz
ASKER CERTIFIED SOLUTION
Avatar of sompol_kiatkamolchai
sompol_kiatkamolchai
Flag of Thailand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I just give you some part of sample application if you need more please feel free to ask from me.
Avatar of Gar04
Gar04

ASKER

hey sompol,
can you explain logically how the code works and how it interacts with the other code a little,
as i am a little confused with it right now???
Gaz
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For my sample application
I am going to explain MVC in more detail.
MVC --> Model-View-Controller
this model separate application in to three component which would be easier to maintain and develop.
Model --> Business Model, Data Model represent by Book.java,BookBean.java
View --> User Interface (JSP)
Controller --> Control the flow of application by using Servlet.

After reiview your code I see that you use resultset in JSP, I think it should be better to move that to javabean(like Book.java in my sample) and return as a list of data instead.

If you agree that MVC is good and you want to learn it more, I suggest you to look at Struts which is a very good framework to do MVC in web application.

Hope this help.
Avatar of Gar04

ASKER

thanks sompol
this has helped a lot
i managed to get my application working
it does not adhere exactly to MCV model you suggested
but it does use a good deal of the design strategy
because i use JSP and JavaBeans
i guess that the java beans communicate with servlets in the background

can this be called MCV???
thank you for the explanation, i will take your advise about struts!!

Gaz
:)