1 16 package org.directwebremoting.servlet; 17 18 import java.io.IOException ; 19 import java.io.PrintWriter ; 20 21 import javax.servlet.http.HttpServletRequest ; 22 import javax.servlet.http.HttpServletResponse ; 23 24 import org.directwebremoting.extend.Handler; 25 import org.directwebremoting.extend.Remoter; 26 import org.directwebremoting.util.LocalUtil; 27 import org.directwebremoting.util.MimeConstants; 28 29 33 public class InterfaceHandler implements Handler 34 { 35 38 public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException 39 { 40 String scriptName = request.getPathInfo(); 41 scriptName = LocalUtil.replace(scriptName, interfaceHandlerUrl, ""); 42 scriptName = LocalUtil.replace(scriptName, PathConstants.EXTENSION_JS, ""); 43 String path = request.getContextPath() + request.getServletPath(); 44 45 String script = remoter.generateInterfaceScript(scriptName, path); 46 47 response.setContentType(MimeConstants.MIME_PLAIN); 51 PrintWriter out = response.getWriter(); 52 out.print(script); 53 } 54 55 59 public void setRemoter(Remoter remoter) 60 { 61 this.remoter = remoter; 62 } 63 64 67 protected Remoter remoter = null; 68 69 73 public void setInterfaceHandlerUrl(String interfaceHandlerUrl) 74 { 75 this.interfaceHandlerUrl = interfaceHandlerUrl; 76 } 77 78 81 protected String interfaceHandlerUrl; 82 } 83 | Popular Tags |