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

JSP to Bean to Servlet

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Ok, I don't know if I am having a brain freeze this morning or what.
I have a JSP Page with a Form. I have a Form Bean for the data. Then I have a Servlet which uses information from the Bean to put it in a database.
So my question is, when I hit submit, do I need ANOTHER "worker servlet" to put the info into a bean, then forward that on to the DB Servlet? Or should I screw the bean and just call the DB Servlet from the JSP page and use requeset.getParameter() to get all my form data?

GenRocket - Experts at Building Test Data
Eelco den Heijer
Ranch Hand

Joined: Jan 17, 2002
Posts: 61
Current J2EE Fashion dictates that you use some implementation of the MVC pattern One of the consequences of this is that you'll have only one controller servlet, and delegate the actual work to helper classes. In your case, you'd have a database helper that stores the bean state in the database. There are many ways to do MVC these days; Struts is popular example. But before you dive into Struts, I would 'just' re-shuffle your servlets into 1 servlet and 2 helper (if I were you).
Hope this helps.

== <br />Rgrds,<br />Eelco<br /> <br />SCJP, SCJD, SCBCD, SCWD, SCEA
I agree. Here's the link:
subject: JSP to Bean to Servlet
It's not a secret anymore!