%@ page language="java" contentType="text/html" import="myDB.*" %>
Create a new Account
<% AccountTableInteraction dti = new AccountTableInteraction();
String result = dti.insertTuple( dbBean, true );
// insertTuple of DeptTableInteraction will returns a non-empty
// string only if something goes wrong.
// .. if result is null, then the Account table was updated
if ( result != null && result.equals("account") ) {
// a matching Account record was found
dbBean.setErrorMsg("Specified Account is active, can't update.");
//dbBean.setCustNo(null);
session.invalidate();
%>
<%
}
else if ( result != null && result.equals("nocontact") ) {
// no matching Contact record was found
// get Contact info & insert new tuples to Contact & Account
%>
<%
}
else if ( result != null ) {
dbBean.setErrorMsg( result );
session.invalidate();
%>
<%
}
// if here then the Account table was updated
// retrieve all tupe from the table. This function will return a
// message (not null) if something goes wrong as we retrieve tuple.
result = dti.retrieveAllTuples();
if( result != null ) {
dbBean.setErrorMsg( result );
%>
<%
}
// Once we get to this point, we must have been able to insert the
// tuple in the database and query the database without any problem.
// Let's write out the
// contents of the database table in which we inserted this tuple
// and print it using an HTML table.
%>
<%
while( dti.hasMoreTuples() ) {
// notice the following jsp line allows us to execute a Java *expression*
// (in this case, dti.getOneTupleInHTMLtableFormat) and write its result in the
// html file that is being generated by this jsp file. Please notice the = after %.
%>
<%= dti.getOneTupleInHTMLtableFormt() %>
<%
}
%>