tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Engel" <BEn...@ipsos-asi.com>
Subject Re: Servlet to JSP
Date Fri, 12 Jan 2001 20:29:01 GMT
Yes you can use request.getParameter("Parm Name") in your JSP to get 'get' and 'post' data.

The best way, IMO, is to make a Java Bean that builds this HTML table.  

Kinda off topic but you may want to use a String buffer instead of a String for your HTML
return var. For large tables this will dramatically speed up creation due to the fact the
JVM must allocate your HTMLRet String everytime it appends to it where as a Stringbuffer appends
to a single instance of itself.  I learned this hard way :-) 

Hope this helps.....



>>> edilmar@intersite.com.br 01/11/01 04:05PM >>>
Hi,

I have used JBuilder + JDK 1.3 + JSDK 2.2 + Tomcat 3.2.1
to build only servlets. However, the web designer would
like more easily to format the HTML page. Then, I thought
about using JSP+servlets.

Look at this simple example:

I have a servlet that receives a request and needs to
run a SQL like:
    "Select Name,Address From Client Order By Name"
Then, it returns a HTML page with this code:
    HTMLRet = "<table border=0>" +
      "<tr><td>Name</td><td>Address</td></tr>";
    Query.first();
    for (i = 0; i < Query.rowCount(); i++) {
      HTMLRet += "<tr><td>" + Query.getString("Name") + "</td>" +
        "<td>" + Query.getString("Address") + "</td></tr>"
      Query.next();
    }
    HTMLRet += "</table>"
    // now the normal code to return HTMLRet using out...

The code is something more complex from above, because there is
many places where the HTML code to return is linked to some business
logical, what makes using only JSP very complicated.

Then, imagine webdesigner tells me about changing the font face/size
of "Name" column and font color of "Address". I need to recompile the
code to do this.

I would like to write all business logical into a servlet and send
the "Query" variable to JSP. Then, at JSP, the webdesigner would do
anything into layout. Is it possible to send the Query to JSP ???


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org 
For additional commands, email: tomcat-user-help@jakarta.apache.org 



Mime
View raw message