Hi,
Im trying load an image from the server using RPC, the problem is
that it always fails to load the image and throws the following error:
com.google.gwt.user.client.rpc.StatusCodeException: 403 <html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1"/>
<title>Error 403 FORBIDDEN</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /diskmonitor/. Reason:
<pre> FORBIDDEN</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
....
Im implementing my classes as the following:
public class ChartImage extends Image {
private UpdatePlotsServiceAsync plotService;
public ChartImage(String hostname) {
super();
/*
* Setup connection to chart generator service.
*/
plotService = (UpdatePlotsServiceAsync)
GWT.create(UpdatePlotsService.class);
ServiceDefTarget endpoint = (ServiceDefTarget)plotService;
String url = GWT.getModuleBaseURL()+"";
System.out.println(url);
endpoint.setServiceEntryPoint(url);
/*
* Setup the callback from the chart generator service.
*/
AsyncCallback<String> callback = new AsyncCallback<String>()
{
/*
* If the call was successful, we will get back the name
of the chart
* that was created and stored on the server.
*/
public void onSuccess(String s) {
String chartName = (String)s;
String imageUrl = GWT.getModuleBaseURL() + chartName;
setUrl(imageUrl);
}
/*
* Something went wrong with the call. Handle the issue
how you'd like.
*/
public void onFailure(Throwable ex) {
System.out.println("Failed to load image");
ex.printStackTrace();
}
};
/*
* Make the call to the chart generator service with the
previously created
* callback.
*/
plotService.getImagesPaths("default", callback);
/*
* Since we've made an asynchronous call, we don't need to do
anything further.
* The callback object will handle the remainder of the work
for us.
*/
}
}
The image is generated in the server side using JFreeChart
public class UpdatePlotsServiceImpl extends RemoteServiceServlet
implements UpdatePlotsService {
@Override
public String getImagesPaths(String hostname) {
String chartName = "";
/*
* Create the data for the pie chart
*/
DefaultPieDataset dataset = new DefaultPieDataset();
//Fake Data
dataset.setValue("Available", 71);
dataset.setValue("Used", 39);
String title = "Data at:"+ info.getHostname()+"-"+
info.getLocation();
JFreeChart chart = ChartFactory.createPieChart(title, dataset,
true, false, false);
File file = new File("chart.png");
//Save the image
try {
ChartUtilities.saveChartAsPNG(file, chart, 800, 600);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return file.getName();
}
}
Please help
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.