Java Reference
In-Depth Information
directory of your project. Right-click the project directory in Eclipse and select Build
Add to Build Path . Open the servlet that was automatically created for you
under your src folder. Ours was called . Copy the code from
Listing 9-9 into the servlet.
Listing 9-9. Code for the servlet
package com.kyleroche.sfdcwsc;
import javax.servlet.http.*;
import com.sforce.soap.partner.*;
import com.sforce.soap.partner.sobject.SObject;
@SuppressWarnings("serial") public class HelloWorldServlet extends
HttpServlet {
private String username = "";
private String password = "app1r10#123";
private PartnerConnection connection;
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.getWriter().println("Hello, from");
PrintWriter t = resp.getWriter();
getConnection( t, req);
if ( connection == null ) { return; }
QueryResult result = null;
try {
result = connection.query("select name from Account
limit 10");
} catch (ConnectionException e) {
for (SObject account : result.getRecords()) {
t.println("<li>"+ (String)account.getField("Name") +
Search WWH ::

Custom Search