ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
DemoRequestForm demoForm = (DemoRequestForm) form;
File dir = demoForm.getDir();
String demo = demoForm.getDemo();
String baseUrl = org.vfny.geoserver.util.Requests.getBaseUrl(request);
if (demo == null)
demo = "";
if (demo.equals("")) {
demoForm.setUrl(baseUrl + "wfs");
demoForm.setBody("");
}
String url = org.vfny.geoserver.util.Requests.getBaseUrl(request)
+ "wfs";
File file = new File(dir, demo);
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuffer buf = new StringBuffer();
for (String line = reader.readLine(); line != null;
line = reader.readLine()) {
buf.append(line);
buf.append("\n");
}
if (demo.endsWith(".url")) {
demoForm.setUrl(baseUrl + buf.toString());
demoForm.setBody("");
} else { //demo.endsWith(.xml), but not yet for backwards compatibility.
demoForm.setUrl(url);
demoForm.setBody(buf.toString());
}
// return back to the admin demo
//
return mapping.findForward("welcome.demoRequest");