• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing variable to actionLink tag

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I'm new to JSP and have been looking for an answer to this question for a while. Can anyone tell me how to pass the dirname variable below into the actionLink tag like I've shown below?

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

etc.....

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

Thanks in advance for any help
 
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why could'nt you put Full URL in a variable and do it?...



Since "actionLink" is a custom tag. Check if "href" attribute accepts dynamic/static value...

If its static value, this code will end up in JSP page error...

You can code without scriptlets...

If want to use dirname like variables, you can use "<c:set>" tag and declare the variables in page scope...JSP page will look neat and maintainable
 
John Hills
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply, Ram.

I tried to add the full url in the variable but the hyperlink is returned on the page as <%= dirname %>.

I don't anything about <c:set> so I'll do a little research.

Again, thank you for the direction
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actionLink is not a JSP tag. What framework is it from?
 
John Hills
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's in Aflresco. That's my first mistake and my knowledge wasn't sufficient to recognize that it wasn't a JSP tag.

Regards,
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the Other Frameworks forum.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, if you are new to JSP, you're heading down the wrong path, and doing it rapidly.

Java scriptlets (those constructs surrounded by <% and %>) have been discredited for 10 years now since the introduction of JSP 2. You are writing JSPs as if it were 2001, not 2012. You should start off on the right foot and not be developing bad habits now that you'll just need to unlearn later.

There should be no Java code in a JSP. None. Nada. Zero.

Rather, modern JSP pages should use the JSTL (that's where the aforementioned <c:set> tag comes from) and the EL (Expression Language). I'd suggest you update whatever resource you are using to learn JSP.

I also recommend that newcomers to JSP read the following article:
  • The Secret Life of JSPs
  • The Front Man

  •  
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic