小编Dil*_*B S的帖子

在同一服务器中跨 Web 应用程序共享 servlet 上下文

我在同一个容器 (Tomcat) 中运行的单独 Web 应用程序中有两个 servlet。让应用程序为 app1 和 app2,而 servlet 为 serv1 和 serv2。

我正在使用 serv1(在 app1 中)调用 serv2(在 app2 中)。我还尝试在这两个 servlet 之间共享相同的会话。下面是我的代码片段。

serv1 (app1) :

URLConnection connection = new URL("http://localhost:8080/app2/serv2").openConnection();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));  
HttpSession session = request.getSession(true);  
String sessionId = session.getId();  
ServletContext myContext = getServletContext();
myContext.setAttribute("MYSHAREDSESSIONID", sessionId);
myContext.setAttribute("SHAREDSESSION", session);
Run Code Online (Sandbox Code Playgroud)

serv2(app2)

ServletContext callingContext = getServletContext().getContext("/app1");  
String jsessionId = (String)callingContext .getAttribute("MYSHAREDSESSIONID");
Run Code Online (Sandbox Code Playgroud)

服务器.xml

URLConnection connection = new URL("http://localhost:8080/app2/serv2").openConnection();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));  
HttpSession session = request.getSession(true); …
Run Code Online (Sandbox Code Playgroud)

java tomcat servlets

1
推荐指数
1
解决办法
6279
查看次数

禁用文本选择在使用jquery的IE中不起作用

我尝试使用JQuery禁用文本选择.它在Firefox中运行良好但在IE中运行不正常.我有一个带有id的文本输入字段,比如说123.对于这个元素,不应该允许填写的文本进行选择.任何人都可以提供示例代码吗?我正在使用IE 6.

javascript jquery internet-explorer-6

0
推荐指数
1
解决办法
1752
查看次数