Setting up a class, calling it from html or asp

I am new to Java.  Running this from the command prompt and implementing it to a site are 2 different things!!!  

I have the following compiled into a class.  It works fine from a command prompt "java SendAddress".  I receive the fields below no problem:
/* start
import com.sagent.centrus.*;
import com.sagent.centrus.crp.*;
 
class SendAddress {
    public static void main(String[] args) {
        System.out.println("Send Address");
        try {
 
            // Create the request.
            Request request = new Request();
 
            // Specify the request.
            //    Login information:
            request.setURL("http://Centrus.Sagent.Com/XML");
            request.setUsername("UserName");
            request.setPassword("Password");
 
            //    Specify a record to be matched:
            InputRecord matchRecord = request.getMatchRecordset().addRecord();
            matchRecord.addField("locator", "gdt", "addressLine", "999 18th Street #2740");
            matchRecord.addField("locator", "gdt", "city", "Denver");
            matchRecord.addField("locator", "gdt", "state", "CO");
 
            //    Specify the output layout:
            request.getLayoutFields().addDisplayField("locator", "gdt", "addressLine");
            request.getLayoutFields().addDisplayField("locator", "gdt", "addressLine2");
            request.getLayoutFields().addDisplayField("locator", "gdt", "city");
            request.getLayoutFields().addDisplayField("locator", "gdt", "state");
            request.getLayoutFields().addDisplayField("locator", "gdt", "zip");
            request.getLayoutFields().addDisplayField("locator", "gdt", "zip4");
            request.getLayoutFields().addDisplayField("locator", "gdt", "latitude");
            request.getLayoutFields().addDisplayField("locator", "gdt", "longitude");

          // Property we want to set:
            request.getProperties().addProperty("locator", "gdt", "MIXED_CASE", "TRUE");
 
            // Submit the request.  
            Response response = request.submit();
            if (response.getIsInError()) {
                System.err.println("Response error string: " + response.getErrorString());
            }
 
            // Read the results for this match record.
            OutputRecord outputRecord = response.getRecordset(0).getRecord(0);
 
            if (outputRecord.getIsInError()) {
                System.err.println("Error: " + outputRecord.getErrorString());
            } else {
                System.out.println("Enhanced standardized address:");
                System.out.println(outputRecord.getField("locator", "gdt", "addressLine").getValue());
                System.out.println(outputRecord.getField("locator", "gdt", "addressLine2").getValue());
                System.out.println(outputRecord.getField("locator", "gdt", "city").getValue() + ", " +
                   outputRecord.getField("locator", "gdt", "state").getValue() + " " +
                    outputRecord.getField("locator", "gdt", "zip").getValue()+ "-" +
                    outputRecord.getField("locator", "gdt", "zip4").getValue());
                System.out.println("Latitude: " + outputRecord.getField("locator", "gdt", "latitude").getValue());
                System.out.println("Longitude: " + outputRecord.getField("locator", "gdt", "longitude").getValue());
                System.out.println();
            }
 
        } catch (Exception e) {
            System.out.println(e.toString());
        }
    }
}
/*end

The class works with 2 .jar files that I have set in my ClassPath.

Here's what I need to do:
Rather than have the addressLine, City, and Zip filled in in the class, I want them to be sent through a User's HTML or ASP page.

Here's what I need from you:
1. The new class (.java) code to compile will take the variables from an HTML/ASP page.
2.  An HTML or ASP page with all the fields in the class.  When click "Submit", sends the info just as the class above does manually, and populates the page with the result.
2.  How in the heck do I set this all up so it will run in IIS?

I told you I was new at this :)




douglaskarrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SendohCommented:
hi !
would u like to consider JSP ??
think for ur approach is more suitable by using jsp...:)

regards
Sendoh
0
nex1999Commented:
douglaskarr,

 I will try and answer your questions. I take it that you want this to work as a servlet but right now you are not doing it that way. I might try and rewrite your code into a servlet but let me go into your 2 other points.

  1) IIS does not run or handle your servlet code. You need an app server, like Tomcat(free for windows or Unix). I have alos used Suns jsdk2.1 mini app just for testing purposes, it is free also and super easy to setup.

  2)Sound like you dont know how to make a page that passes data to you servlet? Is that what youre after? IF that is the case something very simple like this:

<html>
<head>
<title>Servlet Test</title>
</head>
<body bgcolor="#FFFFFF">
<Form action="http://www.yoursite.com:8080/examples/servlet/AcceptInput" Method=Post>
 <Table>
  <tr>
    <td>Last Name: </td>
    <td><input name="Last Name" align="left" size"15"> </td>
  </tr>

  <tr>
    <td>First Name </td>
    <td><input name="First Name" align="left" size"15"> </td>
  </tr>

  <tr>
    <td>Age: </td>
    <td><input name="Age" align="left" size"2"> </td>
  </tr>
 </Table>
 <input type="submit" name="Submit" value"submit">
 <input type="reset" value=Reset>
</Form>
</body>
</html>

This will pass the values to a servlet named AcceptInput. The servlet look like this:

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

public class AcceptInput extends HttpServlet {
  //process the HTTP Get Request
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {
     doPost(request, response);
    }

    public void init(ServletConfig config)
    throws ServletException
    {
      //always pass theServletConfig object to the super class
     super.init(config);

    }

  //process http post request
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    {
     response.setContentType("text/html");
     PrintWriter out = response.getWriter();
     out.println("<html>");
     out.println("<head><title>Example Write Client Data</title></head>");
     out.println("<body>");

      //Get all the parameter names
     Enumeration parameters = request.getParameterNames();
     String param = null;
   
      //Iterate over the names, getting the parameters
     while( parameters.hasMoreElements() )
     {
          param = (String)parameters.nextElement();
          out.println("<bold>" + param +
          " : " + request.getParameter(param) +
          "</bold><Br>" );
     }

     out.println("</body></html>");
     out.close();
    }

  //get servlet info
    public String getServletInfo()
    {
     return "Get client Info";
    }  
}

  3. as far as rewriting your code into a servlet... well I did not do that yet. I might try tomorrow. The examples I gave you are very simple kinda stupid even but it takes input from a HTML form and passes to a servlet and it writes that data back out. Hope it helps you out. If you cannot find jsdk2.1 and you want it let me know. I could email it.

-Nex
0
douglaskarrAuthor Commented:
Nex - that's exactly the guidance I was looking for!  I appreciate your time and effort.  I will review and write these up with the fields necessary.

What is the difference between a class and a servlet?

We do have a servlet engine - I can't remember which.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

nex1999Commented:
douglaskarr,

I am glad you find my information useful.

OK The difference between a class and a servlet? Well A class can be a servlet. It is called a servlet class. Don't mean to sound silly saying that. With java you can make three different types of programs. You can make client-server stand alone programs with/without user interfaces and stuff(by the way that is what you were making). You can make browser based executable programs called applets. These are ok but have lost some popularity they require you downloading them each time and the bigger the program gets the longer the download. Then last Serverside executable code called servlets. I use these quite a bit but everyone is going toward EJB Enterprise Java Beans.

That is my take on it, there is a ton more info out there on this stuff. But you might consider buying one book which is awesome... it is Thinking in Java by Bruce Eckel. His book is great and covers most of the stuff that people want to know.

-Nex
0
nex1999Commented:
Are you still stuck?

Take a look at this: http://www.webdevelopersjournal.com/articles/intro_to_servlets.html

Let me know what is going on k.

-Nex
0
nex1999Commented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nex1999Commented:
0
nex1999Commented:
0
douglaskarrAuthor Commented:
Looks like it doesn't like your text!  You can email it to me at doug@payraisecalculator.com
0
nex1999Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.