Hi All, I am developing a test application using restlet (deployed on tomcat) that would connect to a backend database. The application is successfully deployed on tomcat but the challenge I am facing is passing a parameter using get method.
I am using the following url to fire a request : http://127.0.0.1:8080/restdemo?emp_id=1 I have the following piece of code in the HelloWorldResource. Any pointers would be highly appreciated. public class HelloWorldResource extends Resource { String emp_id ; public HelloWorldResource(Context context, Request request,Response response) { super(context, request, response); System.out.println("Trying to get the entity as a form..."); // If I try to connect through simpleClient code -- the applicaiton hangs here and throws exception Trying to get the entity as a form... //Feb 22, 2008 12:29:51 PM com.noelios.restlet.util.FormReader addParameters //WARNING: Unable to parse a form parameter. Skipping it. //java.net.SocketTimeoutException: Read timed out Form form = request.getEntityAsForm(); System.out.println(" Form as entity from = "+form); // empty form System.out.println(" Form as query String = "+form.getQueryString());; // gets empty string System.out.println("Trying to getParameters..."); StringBuffer sb = new StringBuffer("foo"); for (Parameter p : form) { System.out.println(p); sb.append("field name = "); sb.append(p.getName()); if(p.getName().equals("emp_id")){ emp_id = p.getValue(); } sb.append("value = "); sb.append(p.getValue()); sb.append("\n"); System.out.println(sb.toString()); } //this.emp_id = form.getValues("emp_id"); //this.emp_id = (String) request.getAttributes().get("emp_id"); System.out.println("inside constructor - emp_id = "+emp_id); // prints null // This representation has only one type of representation. getVariants().add(new Variant(MediaType.TEXT_PLAIN)); } I also tried to create a SimpleClient and fire the above request through the client but its not able to establish the connection on port 8080 and times out. Client Code : public class TestClient { /** * Simple HTTP client calling the simple server. */ public static void main(String[] args) throws Exception { // Prepare the REST call. Request request = new Request(); // Identify ourselves. request.setReferrerRef("http://abc.com/"); // Target resource. request.setResourceRef("http://127.0.0.1:8080/restdemo"); // Action: Get request.setMethod(Method.GET); Form form = new Form(); form.add("emp_id", "1"); //form.add("email", "[EMAIL PROTECTED]"); //form.add("email2", "[EMAIL PROTECTED]"); request.setEntity(form.getWebRepresentation()); // Prepare HTTP client connector. Client client = new Client(Protocol.HTTP); System.out.println("Before making client call"); // Make the call. Response response = client.handle(request); System.out.println("after making client call"); if (response.getStatus().isSuccess()) { // Output the response entity on the JVM console response.getEntity().write(System.out); System.out.println("client: success!"); } else { System.out.println("client: failure!"); System.out.println(response.getStatus().getDescription()); } } } Thanks in advance for the help Nilesh

