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

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 retag edit

## 5 Replies

socorro
15

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 :-)

jumperchen
3909 2 8
http://jumperchen.blogspo...

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.

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 :)

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!

jumperchen
3909 2 8
http://jumperchen.blogspo...

Thanks for the information.

[hide preview]