tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Koscak" <m...@logichip.com.au>
Subject Re: Building output page by page.
Date Tue, 19 Dec 2000 06:10:24 GMT
Thanks for the input Dave,

I have a HTML form that sends a POST request to a Servlet class.  The servlet class interacts
with another Java class that I use to access a MySQL database, and display the results.

Browser(FORM)-->Servlet-->JavaDBAccess&display-->Browser(HTML Display)


When accessing the database on the first instance a result set is returned.

ResultSet rs = stmt.executeQuery(queryString);

Now that I have my first aggregation of data I enter a while loop
while( rs.next() )
{
        /* Perform my second query using fields from my earlier query

        /* Now that I have all my data I output my table row using the visibility
        /* I have to my PrintWriter object. Passed earlier from my Servlet class.
}//end while

/* close any open connections and files 
/* and exit the method.

What I'm really after is similar functionality to say when the Google search engine returns
a result set. 
For example say 100 results are returned. There are ten results per page with each page footer
having
1 2 3 4 5 6 7 8 9 10. Each number being a link to a group of ten records.


        
----- Original Message ----- 
  From: Dave Smith 
  To: tomcat-user@jakarta.apache.org 
  Sent: Sunday, November 19, 2000 11:35 AM
  Subject: Re: Building output page by page.


  Hi Mark,
   
  I'll repeat what I said in my earlier
  response. You are not giving much
  information about what you are doing.
   
  You do mention making "database queries".
   
  Lets assume you are accessing a DB with
  sequel. In that case you can perform the following
  type of query:
   
  select * from some_table where primaryKey > min and primaryKey <= max;
   
  Where min and max are limits you set. 
  This would return a range of records between min and max, including max.
   
  Translating into servlets:
   
  A design that comes easily to mind would
  use a controller servlet and a JSP page.
   
  The controller is going to receive a POST from 
  a webpage... The controller doesn't do anything,
  just redirects output and passes on parameters.
   
  form --> params( min, max) --> controller.
   
  The controller redirects output to a JSP:
   
  controller --> sendRedirect("/some.jsp?min=101&max=200");
   
  The webpage is going to be produced as output
  from a JSP called some.jsp:
   
  JSP --> (current data, 101 through 200) and new form with code for next set of data.
   
  ...
  current data
  ...
   
  <form action="/servlet/Controller" method="POST">
  <input type="hidden" name="min" value="<%=min%>">
  <input type="hidden" name="max" value="<%=max%>">
  <input type="submit" value="Get next one hundred entries">
  </form>
   
   
  If this doesn't make any sense you might want to
  read up on the technology before going much farther.
  A good start would be Java Servlet Programming 
  by Hunter and Crawford.
   
  Dave
    ----- Original Message ----- 
    From: Mark Koscak 
    To: tomcat 
    Sent: Monday, December 18, 2000 5:39 PM
    Subject: Re: Building output page by page.


    Hello again,

    I know someone responded to this message, I was unable to respond and the original message
was deleted. My apologies. (Don't ask long story...)

    At present it takes around 13sec to build a page of 1300 rows over 10MB Lan.  I am pushing
HTML output in a display method using out.println(...); right after my database table queries.

    My aim is to reduce the time it takes to display an initial page to the end user, by breaking
up the output into smaller chunks.  

    There is also a good chance that I will merge the two tables into one to reduce the database
connection requirements.

    Thanks Again.
    Mark

    /****************************************************************************************************************
    *    PREVOIUS MESSAGE
    ****************************************************************************************************************/
     
    Hello everyone,

    I have build a Servlet application that creates a single HTML page with up to 1300 rows
in a table.

    Can anyone give me some links or advice on how I can break this output into HTML pages
with say 100 rows per table, with a corresponding selection bar at the bottom of each screen,
giving the user access to any page they click on?

    Thanks in advance.

    Mark

Mime
View raw message