Wicket会话和Jersey REST Web服务

编程入门 行业动态 更新时间:2024-10-21 06:21:44
本文介绍了Wicket会话和Jersey REST Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当前,我正在为PACS查看器开发REST Web服务(医学图像).该Web服务需要具有加密/模糊的参数,以确保用户不能混淆参数以从其他患者那里获取数据.

Currently I'm developing an REST webservice for an PACS viewer (medical images). This webservice needs to have encrypted/obfuscated parameters to ensure users cant fuzz with the parameters to get data from other patients.

在Wicket面板中设置会话属性:

In an Wicket panel im setting an Session attribute:

wicketSession.setAttribute("study", studyInstanceUID);

我想访问Jersey网络服务中的此属性,但是会话在我的Jersey网络服务中不包含任何属性.似乎没有注入或检索?而是创建一个新的?客户端发送的具有当前会话ID的会话.

I want to access this attribute in the Jersey webservice, but the session doesn't contain any attributes in my jersey webservice. It seems like it is not injected or retrieved? Instead of that it creates a new? session with the current SessionID sent from the client.

我为jersey网络服务创建了一个过滤器和映射器:

I've created an filter and mapper for the jersey webservice:

<filter-mapping> <filter-name>WicketSessionFilter</filter-name> <url-pattern>/pacsviewer/*</url-pattern> </filter-mapping>

但这似乎没有什么区别?我认为我在对Web服务的注入或状态做错了什么?

But this doesn't seem to make any difference? I think I'm doing something wrong with the injection or state of the webservice?

推荐答案

如果编写自己的过滤器,则可以在基础HttpSession中读取与Wicket会话相对应的对象,该对象位于"wicket:$ {filterName}:session"下将以下内容放入web.xml

If you write your own filter you can read in the underlying HttpSession the object corresponding to your Wicket Session is located under the "wicket:${filterName}:session" attribute when you put the following in your web.xml

<filter> <filter-name>SessionFilter</filter-name> <filter-class>org.apache.wicket.protocol.http.servlet.WicketSessionFilter</filter-class> <init-param> <param-name>filterName</param-name> <!-- expose the session of the input example app --> <param-value>wicket.Main</param-value> </init-param> </filter> <filter-mapping> <filter-name>SessionFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

然后,您可以在自己的过滤器中获取带有以下Java代码的Wicket Session对象(例如,添加空检查和其他样板代码):

Then you can get the Wicket Session object with the following Java code in your own filter for example (add null checks and other boilerplate code):

HttpSession session = httpRequest.getSession(false); WebSession wicketSession = session.getAttribute("wicket:wicket.Main:session"); //do whatever you want with this //I think a wicketSession.getAttribute("study")

更多推荐

Wicket会话和Jersey REST Web服务

本文发布于:2023-10-31 06:17:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545264.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Jersey   Wicket   Web   REST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!