Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

seperation of businees logic from presentation layer

Status
Not open for further replies.

abyinsydney

Programmer
Feb 17, 2004
99
AU
greetings fellow citizens

can any body let me know how do i bring the results of java class to html page.
here is my JSP.I wan to seperate the java code put it in a class and then call the results in this JSP.Please see the text below for more explanation


<% String account =(String) session.getAttribute( "account10" );
System.out.println("value for accountno is get the hell out of here " +account); %>



<%@ page import="java.util.ArrayList,
java.util.Iterator,
java.util.List,

java.sql.ResultSet,
java.sql.Statement,
java.sql.DriverManager,
java.sql.Connection"



%>
<%
String name =" ",cifprino=" ",cardno1=" ";
String r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16,r17,r18,r19,r20,r21,r22,r23,r24,r25;
Connection conn = null;


Class.forName("org.gjt.mm.mysql.Driver");
String url="jdbc:mysql://168.217.20.68/archiving";
conn = DriverManager.getConnection (url,"tasol","tasol");
Statement stat=conn.createStatement();
ResultSet rs = stat.executeQuery(" select cust_name,cust_surname,cif_no,last_archive_date,id,cust_title from cif_archive_extract where cif_archive_extract.cif_no = " + cif + " && cif_archive_extract.id = " + select + ""); %>


<%
while(rs.next())
{
r1 = rs.getString("cust_name");
r2 = rs.getString("cust_surname");
r3 = rs.getString("cif_no");
r4 = rs.getString("last_archive_date");

/*r5 = rs.getString("cust_add_line1");
r6 = rs.getString("cust_add_line2");
r7 = rs.getString("cust_add_line3");
r8 = rs.getString("cust_post_code");
r9 = rs.getString("cust_mail_add1");
r10= rs.getString("cust_mail_add2");
r11= rs.getString("cust_mail_add3");
r12= rs.getString("dob");
r13= rs.getString("sex");
r14= rs.getString("marital_status");
r15= rs.getString("home_phoneno");
r16= rs.getString("telphone1");
r17= rs.getString("alt_telphone2");
r18 =rs.getString("buss_telno");
r19 =rs.getString("email_id");
r20 =rs.getString("pre_cust_surname");
r21 =rs.getString("mem_comm");
r22 =rs.getString("shareholder_status");
r23 =rs.getString("tfn_exem_code");
r24 =rs.getString("mem_ceased");
r25 =rs.getString("moi"); **/
String r203=rs.getString("id");
String r200=rs.getString("cust_title");
ResultSet ry = stat.executeQuery("select credit_union from id where id.serial_no ='"+r203+"'");
while(ry.next())
{
String cr= ry.getString("credit_union");
System.out.println("value for credit_union is "+cr);
%>

<div id="Layer3" style="position:absolute; left:9px; top:100px; width:974px; height:33px; z-index:3; background-color: #ffffff; layer-background-color: #ffffff; border: 1px none #000000;"100%" border="0">
<tr>


<table width="100%" border="0">
<tr>
<td><strong><font color="#999999" size="2" face="Verdana, Arial, Helvetica, sans-serif">CIF-Reference
no::</font></strong></td>
<td width="26%"><strong><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<% out.println(""+ r203);%>
-
<% out.println(""+ r3);%>
</font></strong></td>
<td width="33%"><strong> <font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<% out.println(""+ cr);%>
</font></strong> </td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="15%"><div align="left"><font size="2"><strong><font color="#999999" face="Verdana, Arial, Helvetica, sans-serif">Name::</font></strong></font></div></td>
<td colspan="2"><strong><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<% out.println(""+ r1);%>
<% out.println(""+ r2);%>
<% out.println(""+ r200);%>
</font></strong></td>
<td width="15%"><div align="left"><font size="2"><strong><font color="#999999" face="Verdana, Arial, Helvetica, sans-serif">Last
Archive Date</font></strong></font></div></td>
<td width="11%"><div align="left"><font size="2"><strong><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">
<% out.println(""+ r4);%>
</font></strong>
<div id="Layer22" style="position:absolute; width:80px; height:17px; z-index:47; left: 889px; top: 5px;"><strong><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif"><a href="login.jsp">Sign
off</a></font></strong> </div>
</font></div></td>
</tr>
</table>

</tr> </div>
<% } } %>

Above is the JSP i have created i want to seperate the java code(Business Logic)from the presentation layer.Could any please le t me know how to calla java class in to html page.

pointers to sedj,venu and rest of the people in the group


au-revoir
aby
 
You have to use following:

<%@page import="com.package.ClassToUse"%>

Now you can create the object to get the data from

ClassToUse ctu = new ClassToUse();

Sjakie

----------
Yes, the world is full of strange people.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top