on 05-17-2006 10:33 AM
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
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amol,
I changed the html page as below:
<html>
<head>
<title> Vendor Details</title>
<script language="JavaScript">
</script>
</head>
<body bgcolor="#eeeff8">
<center>
<hr>
<h1>Enter the Vendor Number</h1>
<hr>
</center>
<form name=form1 action="http://localhost:8880/contextRoot/Servlet" method="post">
<center>
<input type="text" name="vendno">
<input type="submit" value="submit">
</center>
</form>
</body>
</html>
Now when I click on the submit button it is going to the servlet but no data is displayed.
Is there any problem with the servlet or html?
Please let me know.
Thanks,
Pavan.
Message was edited by: Pavan Panduru
Hi Pavan,
i saw that you have wrapped all your code in try-catch block. If there is an error you can't see it in the browser, vecause you don't write it in the response writer object, but just dump stacktrace in the err stream. You can have a look at the default trace file, or (it would be better) dump this trace in the writer. Here is an example, to put in the catch clause :
java.io.StringWriter temp = new java.io.StringWriter();
PrintWriter ptemp = new PrintWriter(temp);
e.printStackTrace(ptemp);
out.print("<pre><code>" + temp.getBuffer() + "</code></pre>");
I hope this should help to see the real problem.
Regards
Bojidar
Hi,
There is no error like 404Not Found, only blank page is displayed with no contents.
I changed the my program like below:
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>");
}
out.close();
} catch (Exception e) {
java.io.StringWriter temp = new java.io.StringWriter();
PrintWriter ptemp = new PrintWriter(temp);
e.printStackTrace(ptemp);
out.print("<PRE>" + temp.getBuffer() + "</PRE>");
}
}
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", "pavan", "pavan", "en", "dev", "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.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.