Skip to Content
avatar image
Former Member

Servlet Program

Hi,

I want to retrieve the values like vendor number, name, city and PO Box from lfa1 table for that i created a rfc.

I created a html and servlet but when i entered the vendor number into it. No values are displayed.

If I provide the vendor number in the servlet program details are displayed, but when iam provide the vendor number through the html page the servlet is not taking the values.

Iam using Netweaver developer studio proxy's are generated properly for RFC.

Here is my code HTML and Servlet code:

<html>

<head>

<title> Vendor Details</title>

<script language="JavaScript">

function getVendorDetails()

{

document.location = "http://localhost:8880/contextRoot/Servlet";

}

</script>

</head>

<body bgcolor="#eeeff8">

<center>

<hr>

<h1>Enter the Vendor Number</h1>

<hr>

</center>

<form name=form1 action="" method=post>

<center>

<input type="text" name="vendno">

<input type="button" value="Login" onclick = "getVendorDetails()">

</center>

</form>

</body>

</html>

</HEAD>

<BODY BGCOLOR="#FFFFFF">

</BODY>

</HTML>

Servlet Code :

package myPackage;

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import myPackage.util.ZbapistructureType_List;

//import com.sap.aii.proxy.framework.core.SystemFaultException;

import com.sap.mw.jco.JCO;

public class VendorServlet extends HttpServlet {

protected void doPost(

HttpServletRequest request,

HttpServletResponse response)

throws ServletException,IOException {

PrintWriter out = response.getWriter();

String vendno = request.getParameter("vendno");

try

{

JCO.Client jcoClient =

JCO.createClient(

"200",

"pavan",

"pavan",

"en",

"dev",

"00");

jcoClient.connect();

Zbapivendor_Input input = new Zbapivendor_Input();

//input.setVendorno("0000020005");

//input.getVendorno();

input.setVendorno("vendno");

VendorPort_PortType port = new VendorPort_PortType();

port.messageSpecifier.setJcoClient(jcoClient);

Zbapivendor_Output output = port.zbapivendor(input);

ZbapistructureType_List vendorList = output.get_as_listItab();

int listsize = vendorList.size();

for (int i = 0; i < listsize; i++)

{

ZbapistructureType elem = vendorList.getZbapistructureType(i);

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

out.println(elem.getVendor_No()); //+ '\t'

//+ elem.getName());

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

}

}

catch(Exception e)

{

e.printStackTrace();

}

}

protected void doGet(

HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException {

PrintWriter out = response.getWriter();

// String vendno = request.getParameter("vendno");

try

{

JCO.Client jcoClient =

JCO.createClient(

"200",

"abap",

"abap",

"en",

"sapdev",

"00");

jcoClient.connect();

Zbapivendor_Input input = new Zbapivendor_Input();

input.setVendorno("0000020005");

//input.setVendorno("vendno");

//input.setVendorno("vendorno");

VendorPort_PortType port = new VendorPort_PortType();

port.messageSpecifier.setJcoClient(jcoClient);

Zbapivendor_Output output = port.zbapivendor(input);

ZbapistructureType_List vendorList = output.get_as_listItab();

int listsize = vendorList.size();

for (int i = 0; i < listsize; i++)

{

ZbapistructureType elem = vendorList.getZbapistructureType(i);

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

out.println(elem.getVendor_No());

out.println(elem.getName());

out.println(elem.getCity());// + '\t'

//+ elem.getName());

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

}

}

catch(Exception e)

{

e.printStackTrace();

}

}

}

Please help me out.

Thanks,

Pavan.

Message was edited by: Pavan Panduru

Message was edited by: Pavan Panduru

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    May 17, 2006 at 10:12 AM

    Any specific reason you are using

    document.location = "http://localhost:8880/contextRoot/Servlet";

    ??

    instead specify

    http://localhost:8880/contextRoot/Servlet

    as the form action and on click of submit button let the form post the request parameter <b>vendno</b>

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      it seems that "listsize" is 0, that's why there is no iterration passed.

      Could you put

      out.println("listsize="+listsize);
      

      before out.close().