package helloWSclient;

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

public class HelloServlet extends HttpServlet {

	public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
		res.setContentType("text/html");
		PrintWriter pw = res.getWriter();
		pw.println("<HTML><TITLE>CSE 486/586 Web Services</TITLE>");
		HelloClient hc = new HelloClient();
		String server = req.getParameter("server");
		String port= req.getParameter("port");
		String HelloTo = req.getParameter("name");

		String EndPoint = "http://"+server+".cse.buffalo.edu:"+port+"/hello-jaxrpc/hello";
		String result = hc.RemoteCall(EndPoint,HelloTo);
		pw.println("<BODY><p align=\"center\"><BR><BR><strong>"+result+"</strong></p></BODY>");
	}
	
	public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
		doGet(req,res);
	}
}
