0

passing parameters from zk application to (external) web app / jsp page

asked 2012-10-08 03:05:37 +0800

socorro gravatar image socorro
15

Hi,

I'm pretty new with zk, and actually with web app work in general, so forgive me if this is question is simple... From my zk application (in the java code handler of a button, e.g.) I need to redirect to an external web application (a jsp page) and pass parameters in the querystring. I tried several things, none of them seemed to work. For example, I tried:

// java code
Executions.sendRedirect("http://blah.blah.blah/default.jsp?x=y");

// jsp page
String y = (String)request.getAttribute("x");

But the jsp is always getting a null here.

I've also some other things, such as setting attributes and such, but every time my jsp page simeply sees null. Any suggestions are appreaciated!

Thanks, Steve

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2012-10-08 03:07:33 +0800

socorro gravatar image socorro
15

updated 2012-10-08 03:19:08 +0800

p.s. (having trouble editing my comment, so will post a reply):

1) I made a typo, above (I meant to type Executions.getCurrent().sendRedirect(...)
2) I've originally tried (in the jsp) to use request.getParameter() as well; still it's null.
3) I also tried some variations on setting attributes with Executions.getCurrent().setAttribute but that seems to not work across web applications.

Ideas and suggestions would be appreciated :-)

link publish delete flag offensive edit

answered 2012-10-08 09:34:40 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hi,

Have you tried to type the url "http://blah.blah.blah/default.jsp?x=y
in the browser to see if JSP page can retrieve the data?
Because the method of the sendRedirect() is almost the same as that you type in the browser url directly.

link publish delete flag offensive edit

answered 2012-10-08 15:25:43 +0800

socorro gravatar image socorro
15

Jumperchen, thanks for the suggestion. I tried typing the URL directly into the web browser, and the jsp page gets the parameter perfectly (i.e. it is not null). However, when I use Executions.getCurrent().sendRedirect(...) the jsp only sees null. I'm not clear now what this tells me, or how to get past this problem. Suggestions, of course, are welcome :)

link publish delete flag offensive edit

answered 2012-10-10 22:13:35 +0800

socorro gravatar image socorro
15

The issue was CAS and Spring Security, not ZK,
so I was going down a rabbit hole worrying about and/or investigating
ZK. In case anyone else experiences this problem (with CAS and Spring Security):

CAS and Spring Security were altering (via a series of redirects) my
original request and thereby I was losing the original request's
parameters. It took much googling, head scratching, trial and error, and
some luck, but I finally stumbled on this (e.g. in the spring security context file, where I am using spring 2.0 fwiw):

 <!-- CAS processing filter, does the bulk of the work -->
    <bean id="casProcessingFilter"
          class="org.springframework.security.ui.cas.CasProcessingFilter">
        <sec:custom-filter after="CAS_PROCESSING_FILTER" />
        <property name="authenticationManager" 
ref="authenticationManager" />
        <property name="authenticationFailureUrl" value="/" />
        <property name="defaultTargetUrl" value="/" />
    <property name="alwaysUseDefaultTargetUrl" value="false"/>
    </bean>

The key here is the <property name="alwaysUseDefaultTargetUrl"
value="false"/>. This seems to allow the 'original' request (including
any parameters) to be the target url of the final redirect; without
which the redirect merely goes to the "defaultTargetUrl" and that will
not retain the parameters from the original request. I cannot say that I
understand 100 percent of the fine-grained details (of the interactions
within CAS) but that is the high-level explanation. Thanks again!

link publish delete flag offensive edit

answered 2012-10-19 07:36:18 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Thanks for the information.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-10-08 03:05:37 +0800

Seen: 218 times

Last updated: Oct 19 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More