use a declarative block instead.
<%! vs <%
look at this doc:
http://java.sun.com/products/jsp/tags/12/syntaxref12.html
and look at the difference between declaration and scriplet.
You should probably bookmark this page. You'll get alot of answers to
questions like this.
-Tim

-----Original Message-----
From: seiju@home [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 08, 2002 9:43 PM
To: [EMAIL PROTECTED]
Subject: I want to make code shorter.


Hello. I am having codes as below.
I'd like to know how to write them as methods. This is because
 I am writing exactly the same twice which as a result makes
 code long and redundant.
I am imaging for the code to look like:
    if (condition) {
         .....statement....
        func();                 <- created method
    } else {
        .....statement...
        func();                 <- created method
    }


Code I want to write as func();
-------------------------------------------------------
    while(rs.next()) {
        if (condition) {
%>
          ---HTML---
<%
 tableHTML = ---htmlstring---;
%>
<%= tableHTML %>
<%
        ResultSet rs2 = db2.getResultSet(...SQL...);
        ResultSet rs3 = db3.getResultSet(...SQL...);
        while (rs2.next()) {
               .........statement..........
            while (rs3.next()) {
                .......statement..........
            } // rs3 loop
        } // rs2 loop
      } // if
    } // rs loop
%>
-------------------------------------------------------

===========================================================================
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

===========================================================================
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

Reply via email to