on 05-19-2006 5:26 AM
Hi,
Hi,
I created html page where we can enter customer number and using servlet program, i am getting values and displayed in the web page for that I used the html tags in the servlet program. Now, I need to display the values using the JSP page when i used, it is generating errors.
And I used the following code for JSP page :
<%@ page language = "java" %>
<%@ page import = "myPackage.*" %>
<jsp:useBean id ="myId" scope = "session" class = "myPackage.VendorServlet" >
<jsp:setProperty name="myId" property="vendno" param = "vendno"/>
</jsp:useBean>
<html>
<head><title>Vendor Details</title>
</head>
<body>
<%
String number = myId.getVendor_No();
String name = myId.getName();
String city = myId.getCity();
String po = myId.getPo_Box();
%>
</body>
</html>
getVendor_No(), getName(), getCity(), getPo_Box() are the methods present in my Servlet Program. Error is generated becasue of this methods only .
Error message :
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 13 in the jsp file: /Details.jsp
Generated servlet error:
D:\jboss-4.0.1\server\default\work\jboss.web\localhost\contextRoot\org\apache\jsp\Details_jsp.java:67: cannot resolve symbol
symbol : method getVendor_No ()
location: class myPackage.VendorServlet
String number = myId.getVendor_No();
^
For all the four methods I am getting the same errors.
Please help me out.
Thanks,
Pavan.
Hi Pavan,
please post the code of myPackage.VendorServlet .
You are using it as JavaBean, not as servlet. In this case you should follow the Bean's rules - each property should have setter and getter methods , constructed by patterns :
get<Property name> / set<Propert yname>.
For example :
int <b>numGuesses</b>;
public NumberGuessBean() {
}
public int get<b>N</b>umGuesses() {
return numGuesses;
}
public void set<b>N</b>umGuesses(int numGuesses) {
this.numGuesses=numGuesses;
}
Note that the first letter is in upper case.
So i the property for vendor number is "vendno" (as you use this name in setProperty tag), the getter method should be <b>getVendno()</b>.
Bul let me first see bean code.
Regards
Bojidar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Below is my VendorServlet 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");
String number, name, city, poBox;
try {
JCO.Client jcoClient =
JCO.createClient("200", "abap", "abap", "en", "sapdev", "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);
number = elem.getVendor_No();
name = elem.getName();
city = elem.getCity();
poBox = elem.getPo_Box();
out.println("<html><body><table border = 1 ><tr><td>");
out.println("Vendor Number : " + number + "</td></tr><tr><td>" +
"Vendor Name :" + name + "</td></tr><tr><td>" +
"Vendor City : " + city + "</td></tr><tr><td>" +
"Vendor PO Box : " + poBox + "</td></tr></table>");
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>");
*/
out.println("Exception is : " + e.getMessage());
}
}
/*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();
}
}*/
}
Pavan,
i can't see any of getter methods in this code as you said :
"getVendor_No(), getName(), getCity(), getPo_Box() are the methods present in my Servlet Program "
Anyway...
I think that you are misunderstanding servlet and JavaBean functionality.
You can learn more about , using links :
http://java.sun.com/products/servlet/docs.html
http://java.sun.com/products/javabeans/docs/spec.html
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21763498.html
I didn't catch your point, it would be good if you describe what you want to implement at all
Regards
Bojidar
Hi,
My requirement is to get the vendor details. For that i created a BAPI which will take the vendor number as input and the fetch the vendor details like number, name, city and PO.
First created a html file where it takes the vendor number as input and Second
Using SAP netweaver I generated the proxy's basing on the BAPI and I then created servlet program to get the details of the vendors. When i run the html file and pass the vendor number into it. Vendor details are displaying, in my servlet file I used the html tags to display in web page. Now, I want the values which are generated by the servlet should be passed to JSP and then display using JSP.
Thanks,
Pavan.
> Hi,
>
> Yes.
>
> Can u let me know where is the error i am getting, i
> could not trace out the error.
>
> Thanks,
> Pavan.
Here is the same functiolaity like in servlet code, realised by jsp :
<%@ page import="myPackage.util.ZbapistructureType_List"%>
<%@ page import="com.sap.mw.jco.JCO"%>
<%@ page import="myPackage.*"%>
<%
String vendno = request.getParameter("vendno");
String number, name, city, poBox;
JCO.Client jcoClient =
JCO.createClient("200", "abap", "abap", "en", "sapdev", "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);
number = elem.getVendor_No();
name = elem.getName();
city = elem.getCity();
poBox = elem.getPo_Box();
out.println("<html><body><table border = 1 ><tr><td>");
out.println("Vendor Number : " + number + "</td></tr><tr><td>" +
"Vendor Name :" + name + "</td></tr><tr><td>" +
"Vendor City : " + city + "</td></tr><tr><td>" +
"Vendor PO Box : " + poBox + "</td></tr></table>");
out.println("</body></html>");
%>
I hope this helps you.
Regards
Bojidar
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.