INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

passing variable to actionLink

passing variable to actionLink

(OP)
Hi All,
I'm new to JSP. Can anyone tell me how to pass the dirname variable below into the actionLink tag?

<% String dirname="google.com";%>

<a:actionLink href="http://www." + <%= dirname %> target="new" value="click Here" />

Thanks in advance for any help

RE: passing variable to actionLink

CODE

<a:actionLink href="http://www.<%= dirname %>" target="new" value="click Here" />
 

Cheers,
Dian

RE: passing variable to actionLink

(OP)
Thanks for your reply, Dian.

I tried your suggestion but all I get is http://www.<;%= dirname%> in the hyperlink. ActionLink is a custom tag that obviously behaves differently than expected. I'm going to try and use <c:set>

Regards,

RE: passing variable to actionLink

Argh, didn't notice the actionLink thingie. With JSTL would be something like

CODE

<c:set var="dirname" value="www.google.es">
<a:actionLink href="http://${dirname}" target="new" value="click Here" />

 

Cheers,
Dian

RE: passing variable to actionLink

(OP)
thanks for your help, Dian, but it looks like I'll have to abandon the actionLink idea and go back to straight html in the jsp page. When I put the ${dirname} in the actionLink as you suggested, I get http://${dirname} in the hyperlink on the page.

Thanks again.

Regards,

RE: passing variable to actionLink

What about a # instead of $?

CODE

<c:set var="dirname" value="http://www.google.es">
<a:actionLink href="#{dirname}" target="new" value="click Here" />

 

Cheers,
Dian

RE: passing variable to actionLink

(OP)
Hi Dian,
I tried your suggestion

for:
<a:actionLink href="#{dirname}" target="new" value="click Here" />

the page returns the alfresco login url

for:

<a:actionLink href="http://#{dirname}" target="new" value="click Here" />

the page returns http:///

Looks to me like actionLinks do not handle dynamic variables

RE: passing variable to actionLink

Well, at least it looks like the variable is being recognized, despite of the lack of value. The difference between # and $ has to do with when the it's rendered, as shown here

Maybe it's worth to try a scope change, as shown here with something like

CODE

<c:set var="dirname" value="http://www.google.es" scope="session">
<a:actionLink href="#{dirname}" target="new" value="click Here" />
 

Cheers,
Dian

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close