× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: My Java Experience... latest code - critique
  • From: "Stone, Brad V (TC)" <bvstone@xxxxxxxxxxxxxx>
  • Date: Wed, 21 Mar 2001 09:11:19 -0600

Ok, with help from you folks, I wrote some classes.  Basically they allow me
to select a file and output either HTML or XML.  Here is a generic servlet I
wrote using these classes.  They allow the user to select a library, file,
where statement, order statement, which machine to get the data from (we
have many in our network) and how to output the result (HTML or XML for
now).

I'm looking for critique here again.  If you have a question an need to see
source from one of my classes, just let me know.  

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class JavaTest extends HttpServlet
{

  public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
  {
    PrintWriter out=response.getWriter();

    String header = "Group";
    String library = "";
    String file = "";
    String sqlWhere = "";
    String sqlOrder = "";
    String databaseProperties = "";
    String output = "";
    FieldListFormatter listFormatter = new XMLFieldListFormatter();

    try
        {
          library=request.getParameterValues("library")[0].trim();
          file=request.getParameterValues("file")[0].trim();
          sqlWhere=request.getParameterValues("sqlWhere")[0].trim();
          sqlOrder=request.getParameterValues("sqlOrder")[0].trim();
        
databaseProperties=request.getParameterValues("machine")[0].trim();
          output=request.getParameterValues("output")[0].trim();
        }
        catch (Exception e)
        {
    }

    SQLDefinition controlSQL = new SQLDefinition(library + "." + file,
sqlWhere, sqlOrder);
    FieldTableDefinition myTable = new
FieldTableDefinition(databaseProperties, controlSQL);

    if (output.equals("HTML"))
    {
      response.setContentType("text/html");
      listFormatter = new HTMLFieldListFormatter();
      header = "table";

    } else {
      response.setContentType("text/xml");
    }

    out.println("<" + header + ">");

    for (int i = 0; i < myTable.size(); i++)
    {
      myTable.getFieldList(i).setFormatter(listFormatter);
      myTable.getFieldList(i).xmlWrapper="Data";
      out.println(myTable.getFieldList(i).toML());
    }

    out.println("</" + header + ">");

    out.close();
  }

  public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
  {
    doGet(request, response);
  }

}
+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.