Why not write a function called WhereClause():
<%!
public String WhereClause()
{
Vector email = (Vector)session.getAttribute("rep_email");
if (email != null)
{
if (email.size() > 0)
{
if (!firstClause)
{
query += " AND ";
firstClause = false;
}
query += "(email = '" + email.elementAt(0) + "'";
for (int i=1; i
{
query += ") ";
}
}
}
}
%>
Hope this helps,
______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relating to the official business of Laconia Data Systems (LDS) is proprietary to the company. It is confidential, legally privileged and protected by law. LDS does not own and endorse any other content. Views and opinions are those of the sender unless clearly stated as being that of LDS.
The person addressed in the e-mail is the sole authorised recipient. Please notify the sender immediately if it has unintentionally reached you and do not read, disclose or use the content in any way.
LDS can not assure that the integrity of this communication has been maintained nor that it is free of errors, virus, interception or interference.
_______________________________________________
>From: David Castro <[EMAIL PROTECTED]> >Reply-To: [EMAIL PROTECTED] >To: [EMAIL PROTECTED] >Subject: Basic question: repeating code in JSP pages? >Date: Wed, 14 Aug 2002 05:55:06 -0700 >MIME-Version: 1.0 >Received: from hotmail.com ([65.54.237.28]) by hotmail.com with Microsoft SMTPSVC(5.0.2195.4905); Wed, 14 Aug 2002 06:00:57 -0700 >Received: from swjscmail2.java.sun.com ([192.18.99.108]) by hotmail.com with Microsoft SMTPSVC(5.0.2195.4905); Wed, 14 Aug 2002 05:56:13 -0700 >Received: from swjscmail1 (swjscmail1.Sun.COM [192.18.99.107])by swjscmail2.java.sun.com (Postfix) with ESMTPid D4D3022E8D; Wed, 14 Aug 2002 06:52:49 -0600 (MDT) >Received: from JAVA.SUN.COM by JAVA.SUN.COM (LISTSERV-TCP/IP release 1.8d) with spool id 2420948 for [EMAIL PROTECTED]; Wed, 14 Aug 2002 06:51:03 -0600 >Received: from web10005.mail.yahoo.com (web10005.mail.yahoo.com [216.136.130.41]) by swjscmail1.java.sun.com (Postfix) with SMTP id 99F434835 for <[EMAIL PROTECTED]>; Wed, 14 Aug 2002 06:51:02 -0600 (MDT) >Received: from [24.74.213.228] by web10005.mail.yahoo.com via HTTP; Wed, 14 Aug 2002 05:55:06 PDT >Delivered-To: [EMAIL PROTECTED] >Message-ID: <[EMAIL PROTECTED]> >Sender: A mailing list about Java Server Pages specification and reference <[EMAIL PROTECTED]> >In-Reply-To: <[EMAIL PROTECTED]> >Return-Path: [EMAIL PROTECTED] >X-OriginalArrivalTime: 14 Aug 2002 12:56:14.0206 (UTC) FILETIME=[F8BA19E0:01C24391] > >I am creating a JSP application that generates a custom SQL query, based on the >columns and rows that the user wants to see. As such, I have a whole bunch of >repeated code in the page: > >Vector email = (Vector)session.getAttribute("rep_email"); >if (email != null) { > if (email.size() > 0) { > if (!firstClause) { > query += " AND "; > firstClause = false; > } > query += "(email = '" + email.elementAt(0) + "'"; > for (int i=1; i
Chat with friends online, try MSN Messenger: Click Here
=========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com
