Created
August 28, 2012 19:54
-
-
Save sam/3503465 to your computer and use it in GitHub Desktop.
Servlet Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HarborServlet extends HttpServlet { | |
| private ScriptingContainer container; | |
| private HttpServlet servlet; | |
| @Override | |
| public void init() { | |
| String classpath = getServletContext().getRealPath("/WEB-INF/classes"); | |
| List<String> loadPaths = Arrays.asList(classpath.split(File.pathSeparator)); | |
| container = new ScriptingContainer(); | |
| container.getProvider().setLoadPaths(loadPaths); | |
| container.runScriptlet("require 'hello_world'"); | |
| servlet = (HttpServlet) container.runScriptlet("HelloWorld.new"); | |
| } | |
| protected void processRequest(HttpServletRequest request, HttpServletResponse response) | |
| throws ServletException, IOException { | |
| servlet.service(request, response); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| java_import javax.servlet | |
| java_import javax.servlet.http | |
| class HelloWorld < HttpServlet | |
| def do_get(request, response) | |
| response.writer.println "Hello World!" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment