File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes DWR error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "DWR error" Watch "DWR error" New topic

DWR error

srinivas lakshman

Joined: Feb 08, 2012
Posts: 2
Hello All,

I m new to DWR and recently wrote a program to get the values dynaically from the Server.
I get error and the page doesn load the values coming from server. Here is the code.
Any help would be greatly appreciated.

JSP Page - index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Srini DWR Page</title>
<script src="/DWRTest2/dwr/engine.js"></script>
<script type='text/javascript' src='/DWRTest2/dwr/interface/Demo.js'></script>
<script src="/DWRTest2/dwr/util.js"></script>
<script type="text/javascript">

function update() {
var name = dwr.util.getValue("demoName");
Demo.sayHello(name, function(data) {
dwr.util.setValue("demoReply", data);

function cloneSearch() {
var sel = dwr.util.getValue("selectText");
dwr.util.addOptions("selectText", [ "one", "two", "three" ]);
dwr.util.setValue("selectText", sel);

function getModels() {
var make = dwr.util.getValue("makes");
Demo.getModels(make, function(reply) {
dwr.util.addOptions("models", reply);


<input type="text" id="demoName"/>
<input value="Send" type="button" onclick="update()"/>
Reply: <span id="demoReply"></span>
<input type="button" value="Search" onclick="cloneSearch()"/>
<select id="selectText"></select>
<select id="makes" onchange="getModels"><option id="Aston">Aston</option><option id="BMW">BMW</option></select>
<select id="models"></select>

web.xml -

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="" xmlns="" xmlns:web="" xsi:schemaLocation="" id="WebApp_ID" version="2.5">




<?xml version="1.0" encoding="UTF-8"?>
"-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"

<create creator="new" javascript="Demo">
<param name="class" value="com.test.Demo"/>

package com.test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Demo {
public String sayHello(String name) {
return "Hello, " + name;

public String[] cloneSearch2(){
String[] arry = new String[]{"1one","2Two","3Three"};
return arry;

public String[] getModels(String make){
String[] arry = new String[]{"1one","2Two","3Three"};
return arry;

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
Please use code tags, and you did not say what the error is.

srinivas lakshman

Joined: Feb 08, 2012
Posts: 2

Apologies on that. The error is that when i select the type of Car, the drop down next to it is not getting populated from the server.
The first code snipet invloves in generating string from the server. That works. Where as from getModels() function, the values aren't getting populated.
Here is the code in the code tag. Any help is greatly appreciated.




I agree. Here's the link:
subject: DWR error
It's not a secret anymore!