質問

I'm developing a portlet deployed under weblogic server 10. Amongst other functionalities, my portlet need to get some parameters passed in the URL and do something according to each one. Well, my problem is that i can't figure out the right way to get the query string. I have found different approaches on the internet, but none of them seems to work on weblogic. I am able to get the server name, context path or whatever, but no query string..

Does anybody know any solution to this ? Or at least give me a clue ? If i take them from JSP, am i able to pass them over to the .java class ?

Best regards, Adrian Zaharia

役に立ちましたか?

解決

Portlet technology provides two major types of urls - ActionURL and RenderURL.

ActionURL triggers processAction (action phase method) on the target portlet whereas RenderURL forwards the request to doView (render phase method) on the target portlet.

Also, note that its best to avoid any portlet state change in the render phase.

Typically the jsp passing parameters over to portlet would do...

        PortletURL url = renderResponse.createActionURL();
        url.setParameter("paramName", "paramVal");

        <a href="<%=url.toString()%>">Click Me</a>

The portlet retrieving parameter in processAction or Action Phase would do...

        public void processAction(ActionRequest request, ActionResponse response)
        throws PortletException, PortletSecurityException, IOException {
               ....
               String paramVal = (String)request.getParameter("paramName");
               ....
        }

他のヒント

I found a better solution for my needs. I was able to get the httprequest like this:

HttpServletRequest httpRequest = (HttpServletRequest) request.getAttribute("javax.servlet.request");

Then get the entire url from a header called referer:

String referer = httpRequest.getHeader("referer");

Thought i should share. Thanks !

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top