File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Passing variable to actionLink tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Passing variable to actionLink tag" Watch "Passing variable to actionLink tag" New topic
Author

Passing variable to actionLink tag

John Hills
Greenhorn

Joined: Feb 18, 2012
Posts: 3
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
Ram Narayan.M
Ranch Hand

Joined: Jul 11, 2010
Posts: 247

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


SCJP 6 [SCJP - Old is Gold]
John Hills
Greenhorn

Joined: Feb 18, 2012
Posts: 3
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

actionLink is not a JSP tag. What framework is it from?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
John Hills
Greenhorn

Joined: Feb 18, 2012
Posts: 3
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

Moved to the Other Frameworks forum.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

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

  •  
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Passing variable to actionLink tag
     
    Similar Threads
    Tag file directives and actions
    What are <variable> & <name-from-attribute> tags in the TLD??
    IO
    How to Introduce a Button That Controls All Other Links in a Web Page
    Problems using custom tag with javascript