I have two class files, one is a Servlet that reads information from a form
on submit, the other accesses a database. The purpose of the application is
to take the information from a user, add it to a database and return data
from the database to the user.

The Servlet class correctly reads the input from the user and returns
(echoes) information to the user using RequestDispatcher. The database
access class correctly inserts and selects data from the database.

My question is how to pass the information between class instances, i.e.
pass user input from the Servlet to the JDBC class and pass data from the
JDBC class to the Servlet.

I would like to know what methods to use in as much detail as possible
including declarations. Thanks in advance.

details for others learning:

JSP or HTML -
// form
<form action="ServletName" method="post" >
<input type="text" name="fieldName" >
<input type="submit>
</form>


Servlet -
// read input from form
String fieldName = request.getParameter("fieldName"); // HttpServletRequest
// output data to user
request.setAttribute("fieldName", fieldName);
PrintWriter out = response.getWriter();
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher("/more_html.jsp"));
  dispatcher.include(request, response);
out.println( fieldName);

DB access class -
// straightforward JDBC


Neill Laney
http://home.nc.rr.com/nlaney

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to