forked from micw/php-java-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhpHttpScriptServlet.java
More file actions
65 lines (55 loc) · 2.21 KB
/
Copy pathPhpHttpScriptServlet.java
File metadata and controls
65 lines (55 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*-*- mode: Java; tab-width:8 -*-*/
package php.java.script.http;
import javax.script.ScriptEngine;
import javax.script.http.SimpleHttpScriptContext;
import javax.script.http.HttpScriptContext;
import javax.script.http.HttpScriptServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author jostb
*
*/
public abstract class PhpHttpScriptServlet extends HttpScriptServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
SimpleHttpScriptContext.initializeGlobal(config);
}
/* (non-Javadoc)
* @see javax.script.http.HttpScriptServlet#getContext(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public HttpScriptContext getContext(HttpServletRequest req,
HttpServletResponse res) throws ServletException {
PhpHttpScriptContext context = new PhpHttpScriptContext();
context.initialize(this, req, res);
return context;
}
/* (non-Javadoc)
* @see javax.script.http.HttpScriptServlet#getEngine(javax.servlet.http.HttpServletRequest)
*/
public ScriptEngine getEngine(HttpServletRequest request) {
return new PhpHttpScriptEngine(request);
}
/* (non-Javadoc)
* @see javax.script.http.HttpScriptServlet#releaseEngine(javax.script.ScriptEngine)
*/
public void releaseEngine(ScriptEngine engine) {
((PhpHttpScriptEngine)engine).release();
}
/* (non-Javadoc)
* @see javax.script.http.HttpScriptServlet#getContext(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public HttpScriptContext getContext(ServletRequest req, ServletResponse res) throws ServletException, ClassCastException {
return getContext((HttpServletRequest) req, (HttpServletResponse)res);
}
/* (non-Javadoc)
* @see javax.script.http.HttpScriptServlet#getEngine(javax.servlet.http.HttpServletRequest)
*/
public ScriptEngine getEngine(ServletRequest req) throws ClassCastException {
return getEngine((HttpServletRequest) req);
}
}